Skip to content

Conversation

@KaiqiJinWow
Copy link
Collaborator

@KaiqiJinWow KaiqiJinWow commented May 21, 2025

Which Delta project/connector is this regarding?

  • Spark
  • Standalone
  • Flink
  • Kernel
  • Other (fill in here)

Description

Introduce IcebergCompatV3 feature, which requires row tracking and column mapping to be enabled. We block the disabling or enabling IcebergCompatV3 on existing tables.

This PR is a stacked PR and based on #4731 and #4732

How was this patch tested?

Unit tests and e2e tests.

Does this PR introduce any user-facing changes?

@KaiqiJinWow KaiqiJinWow changed the title [WIP][Kernel] IcebergCompatV3 [WIP][Kernel] Introduce IcebergCompatV3 Jun 9, 2025
@murali-db murali-db mentioned this pull request Jun 9, 2025
5 tasks
@KaiqiJinWow KaiqiJinWow force-pushed the stack/add_iceberg_compatV3 branch from 018b936 to efa3249 Compare June 9, 2025 22:39
@KaiqiJinWow KaiqiJinWow force-pushed the stack/add_iceberg_compatV3 branch from efa3249 to 7e10891 Compare June 9, 2025 22:39
@KaiqiJinWow KaiqiJinWow changed the title [WIP][Kernel] Introduce IcebergCompatV3 【Kernel] Introduce IcebergCompatV3 Jun 9, 2025
@KaiqiJinWow KaiqiJinWow changed the title 【Kernel] Introduce IcebergCompatV3 [Kernel] Introduce IcebergCompatV3 Jun 9, 2025
@KaiqiJinWow KaiqiJinWow requested a review from lzlfred June 9, 2025 22:56
|| dataType instanceof ArrayType
|| dataType instanceof MapType
|| dataType instanceof StructType
|| dataType instanceof VariantType;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this


@Override
List<TableFeature> requiredDependencyTableFeatures() {
return Stream.of(ICEBERG_COMPAT_V3_W_FEATURE, COLUMN_MAPPING_RW_FEATURE).collect(toList());
Copy link
Contributor

Choose a reason for hiding this comment

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

add row tracking here ?

field -> {
DataType dataType = field.getDataType();
// IcebergCompatV3 supports variants and all the IcebergCompatV2 supported types
return !isSupportedDataTypesForV2(dataType) && !(dataType instanceof VariantType);
Copy link
Contributor

Choose a reason for hiding this comment

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

make the new v3 types in a separate list to facilitate adding more later.

@KaiqiJinWow KaiqiJinWow self-assigned this Jun 10, 2025
@raveeram-db raveeram-db requested review from allisonport-db, huan233usc and scottsand-db and removed request for lzlfred June 10, 2025 17:50
* Compatibility V3 protocol.
*
* @see <a
* href="https://github.com/delta-io/delta/blob/master/PROTOCOL.md#delta-iceberg-compatibility-v3">
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems like this link doesn't exists?

}

protected static boolean isAdditionalSupportedDataTypesForV3(DataType dataType) {
return dataType instanceof VariantType;
Copy link
Collaborator

Choose a reason for hiding this comment

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

also check isSupportedDataTypesForV2 and the new type supported?

private static final IcebergCompatV3MetadataValidatorAndUpdater INSTANCE =
new IcebergCompatV3MetadataValidatorAndUpdater();

private static final IcebergCompatRequiredTablePropertyEnforcer ICEBERG_COMPAT_V3_CM_REQUIREMENT =
Copy link
Collaborator

Choose a reason for hiding this comment

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

create a follow up task to define this check in the base class and reuse it. You can post that as the first PR precuros to this PR.

Comment on lines 92 to 96
if (Boolean.parseBoolean(
inputContext.newMetadata.getConfiguration().getOrDefault(prop, "false"))) {
throw DeltaErrors.icebergCompatIncompatibleVersionEnabled(
INSTANCE.compatFeatureName(), prop);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you check if you use the utility in TableConfig.PROP.fromMetadata here?

}
};

private static final IcebergCompatCheck ICEBERG_COMPAT_V3_CHECK_HAS_ALLOWED_PARTITION_TYPES =
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment here. create common check in the base class.

// this to allow checking the partition columns aren't changed
};

private static final IcebergCompatCheck ICEBERG_COMPAT_V3_CHECK_HAS_SUPPORTED_TYPE_WIDENING =
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here.

* Base suite containing common test cases for Delta Iceberg compatibility features.
* This includes tests that apply to both V2 and V3 compatibility modes.
*/
trait DeltaIcebergCompatBaseSuite extends DeltaTableWriteSuiteBase with ColumnMappingSuiteBase {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note to Reviewers: I move some common test cases from DeltaIcebergCompatV2Suite so that these test cases could be shared with both DeltaIcebergCompatV2Suite and DeltaIcebergCompatV3Suite. Since IcebergCompatV3 does not support being disabled or enabled for existing tables, so the existing tables related suites are kept in DeltaIcebergCompatV2Suite

@KaiqiJinWow KaiqiJinWow requested a review from vkorukanti June 12, 2025 23:40
@KaiqiJinWow KaiqiJinWow requested a review from vkorukanti June 13, 2025 16:47
}
}

test("subsequent writes to icebergCompatV3 enabled tables doesn't update metadata") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: this test case seems a bit over kill to me, what's the case for other iceberg compat?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@KaiqiJinWow KaiqiJinWow requested a review from huan233usc June 13, 2025 20:34
|| Boolean.parseBoolean(
metadata
.getConfiguration()
.getOrDefault(TableConfig.ICEBERG_COMPAT_V3_ENABLED.getKey(), "false"))) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please create a utility method in IcebergCompatMetadataValidatorAndUpdader and move this code there. Also use TableConfig.ICEBERG_COMPAT_V3_ENABLED.fromMetadata()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

s"icebergCompat$icebergCompatVersion does not support type widening present in table"))
}

Seq("id", "name").foreach { existingCMMode =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this test be also added to IcebergWriterCompatV1MetadataValidatorAndUpdaterSuite?

Copy link
Collaborator

Choose a reason for hiding this comment

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

or is it wrong in the first place where it is ran as part of the WriterCompatV2 suite, but it is always using icebergCompatV2?

Copy link
Collaborator

@vkorukanti vkorukanti Jun 14, 2025

Choose a reason for hiding this comment

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

Qn: does icebergCompatV3 can work with either modes or just id?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test case previously existed only in the icebergCompatV2 suite. Since icebergCompatV2 supports both column mapping modes, whereas icebergWriteCompatV2 supports only the id mode, the test—which only verifies whether the column mapping modes can be enabled with icebergCompatV2—belongs specifically in the icebergCompatV2 suite. Therefore, it’s appropriate to keep it there rather than moving it to the shared base suite.

}
}

Seq("id", "name").foreach { existingCMMode =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

why can't move this to the base class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same reason #4595 (comment)

" not compatible with icebergCompatV3 requirements"))
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about the test where row tracking is enabled (if not enabled)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

also only icebergCompatV3 is enabled and not others compact versions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

are we getting the coverage for type widening?

Copy link
Collaborator

Choose a reason for hiding this comment

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

also deletion vectors? do we need to test anything there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

type widening and deletion vectors(we mark isDeletionVectorsSupported as true here) are in base class

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added case to verify row tracking is auto enabled and only icebergCompatV3 is enabled with not others compact versions.

@KaiqiJinWow KaiqiJinWow requested a review from vkorukanti June 16, 2025 17:59
@KaiqiJinWow KaiqiJinWow force-pushed the stack/add_iceberg_compatV3 branch from 1886ff0 to a80d79a Compare June 16, 2025 18:06
Copy link
Collaborator

@vkorukanti vkorukanti left a comment

Choose a reason for hiding this comment

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

Looks great!

one test on variant support (not supported yet)
replace table case

Comment on lines 256 to 260
if (isIcebergCompatV2Enabled) {
IcebergCompatV2MetadataValidatorAndUpdater.validateDataFileStatus(dataFileStatus);
} else if (isIcebergCompatV3Enabled) {
IcebergCompatV3MetadataValidatorAndUpdater.validateDataFileStatus(dataFileStatus);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can use isIcebergCompatEnabled and just call IcebergCompatMetadataValidatorAndUpdater.validateDataFileStatus

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would push back this as IcebergCompatMetadataValidatorAndUpdater.validateDataFileStatus also need a String compatFeatureName to better expose the error message, so it would not reduce the code imo.

@KaiqiJinWow KaiqiJinWow requested a review from vkorukanti June 17, 2025 16:23
Copy link
Contributor

@lzlfred lzlfred left a comment

Choose a reason for hiding this comment

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

lgtm

@vkorukanti vkorukanti merged commit 7e5b26f into delta-io:master Jun 17, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants