Skip to content

HIVE-29546: Iceberg: [V3] Support of ROW LINEAGE in COMPACTION#6407

Open
kokila-19 wants to merge 1 commit intoapache:masterfrom
kokila-19:row_lineage_comp
Open

HIVE-29546: Iceberg: [V3] Support of ROW LINEAGE in COMPACTION#6407
kokila-19 wants to merge 1 commit intoapache:masterfrom
kokila-19:row_lineage_comp

Conversation

@kokila-19
Copy link
Copy Markdown
Contributor

@kokila-19 kokila-19 commented Apr 3, 2026

What changes were proposed in this pull request?

Preserve Iceberg v3 row lineage during compaction by generating compaction rewrite queries that carry row-lineage values correctly.
Propagate the row-lineage flag reliably into write job properties using RowLineageUtils.isRowLineageInsert(conf).

Why are the changes needed?

Compaction is implemented as INSERT OVERWRITE, without special handling it can rewrite data with new row-lineage values.

Does this PR introduce any user-facing change?

No, this PR does not introduce any user-facing changes. It adds internal support for row lineage during compaction.

How was this patch tested?

qtest

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 7, 2026

@kokila-19 kokila-19 changed the title [WIP] Don't Review HIVE-29546: Iceberg: [V3] Support of ROW LINEAGE in COMPACTION Apr 8, 2026
@kokila-19 kokila-19 marked this pull request as ready for review April 8, 2026 04:27
Comment on lines +102 to +121
private static void setRowLineageConfFlag(Configuration conf, boolean enabled) {
if (enabled) {
conf.setBoolean(SessionStateUtil.ROW_LINEAGE, true);
} else {
conf.unset(SessionStateUtil.ROW_LINEAGE);
}
}

/**
* Enable the row lineage session flag for the current statement execution.
* Returns {@code true} if the flag was enabled
*/
public static void enableRowLineage(SessionState sessionState) {
setRowLineageConfFlag(sessionState.getConf(), true);
}

public static void disableRowLineage(SessionState sessionState) {
setRowLineageConfFlag(sessionState.getConf(), false);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't we directly do

  public static void enableRowLineage(SessionState sessionState) {
    sessionState.getConf().setBoolean(SessionStateUtil.ROW_LINEAGE, true);
  }

  public static void disableRowLineage(SessionState sessionState) {
    sessionState.getConf().setBoolean(SessionStateUtil.ROW_LINEAGE, false);
  }

You have javadoc for one & not for others, considering it is a util class we can drop it

Comment on lines +202 to +206
private static String buildSelectColumnList(Table icebergTable, HiveConf conf) {
return icebergTable.schema().columns().stream()
.map(Types.NestedField::name)
.map(col -> HiveUtils.unparseIdentifier(col, conf))
.collect(Collectors.joining(", "));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this logic should kick in like this. If rowLineage isn't enabled, it should just return *, like before.
If rowLineage is enabled add the name from ROW_LINEAGE_COLUMNS_TO_FILE_NAME

Comment on lines +89 to +92
public static String getRowLineageSelectColumns(boolean rowLineageEnabled) {
return rowLineageEnabled
? ", " + VirtualColumn.ROW_LINEAGE_ID.getName() + ", " + VirtualColumn.LAST_UPDATED_SEQUENCE_NUMBER.getName()
: "";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change it getRowLineageColumnsForCompaction

Comment on lines +80 to +83
if (rowLineageEnabled) {
RowLineageUtils.enableRowLineage(sessionState);
LOG.debug("Row lineage flag set for compaction of table {}", compactTableName);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we not do it when we add the columns for row lineage, would avoid redundant checking rowLineageEnabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants