Allow enabling CDF using ALTER TABLE SET PROPERTIES#16221
Allow enabling CDF using ALTER TABLE SET PROPERTIES#16221homar wants to merge 2 commits intotrinodb:masterfrom
Conversation
There was a problem hiding this comment.
Can we create a helper method to get the MetadataEntry? and we can use that helper method in appendTableEntries as well?
There was a problem hiding this comment.
I tried but it became messy, I will do it as another PR, ok ?
There was a problem hiding this comment.
Since we are now supporting additional property in ALTER TABLE ..., protocolEntry should be appended if present.
There was a problem hiding this comment.
So I've just checked, I did run this three operations:
CREATE TABLE student31 (id INT, name STRING, age INT) USING DELTA LOCATION XXXX
INSERT INTO student31 VALUES(1, 'homar', 13);
ALTER TABLE student31 SET TBLPROPERTIES (delta.enableChangeDataFeed = true)
The last one resulted in creation of 00000000000000000002.json.
And it has protocol entry that looks like this:
{
"protocol": {
"minReaderVersion": 1,
"minWriterVersion": 4
}
}
So I don't think there is a need to add changeDataFeed there
There was a problem hiding this comment.
Yes, right the protocol version will not get updated and use the previous protocol version.
My point was whether adding a protocol entry in the transaction log is necessary if the user has not set reader_version or writer_version property using ALTER TABLE ....
CC: @alexjo2144
There was a problem hiding this comment.
oh ok I see what you mean, so imho if we throw when writerVersion is too low then protocol version doesn't change here so there is no need to append it. i will change this
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
testAlterTableWithUnsupportedProperties needs to be updated.
There was a problem hiding this comment.
Can we have tests with a combination of change_data_feed_enabled, ALTER_TABLE, and writer_version?
There was a problem hiding this comment.
Something like testCreateTableWithCdfEnabledAndUnsupportedWriterVersionFails, testCreateTableAsWithCdfPropertyWriterVersionNotUpgraded
There was a problem hiding this comment.
I modified the test I added and renamed it to testSettingChangeDataGeedEnabledProperty
There was a problem hiding this comment.
nit: bring configuration inside the subsequent if - this is where it is only used (at the moment).
ffdab4f to
d18c8fe
Compare
|
Please resolve conflicts. #16165 is merged now. |
d18c8fe to
b7332d5
Compare
There was a problem hiding this comment.
IMO, I'd go with earlier implementation instead of adding methods in ProtocolEntry.
Optional<ProtocolEntry> protocolEntry = Optional.empty();
if (readerVersion.isPresent() || writerVersion.isPresent()) {
protocolEntry = Optional.of(new ProtocolEntry(
readerVersion.orElse(currentProtocolEntry.getMinReaderVersion()),
writerVersion.orElse(currentProtocolEntry.getMinWriterVersion())));
}There was a problem hiding this comment.
ok, but i liked mine version ;)
There was a problem hiding this comment.
Can we keep this and verify the error does not include change_data_feed_enabled?
There was a problem hiding this comment.
I think this should work. since we are not enabling cdf. enabling cdf with writer_version less than 4 should throw exception.
There was a problem hiding this comment.
But in this case we don't set writer_version so it is set to 2, it is verified at the beginning of this test. I thought we agreed that we should not increase writer_version silently.
There was a problem hiding this comment.
yes right, we are not increasing writer_version silently.
change_data_feed_enabled = false is the same as not setting change_data_feed_enabled.
In my opinion, executing CREATE TABLE test (a INT) WITH (change_data_feed_enabled = false, writer_version = 3) or CREATE TABLE test (a INT) WITH (change_data_feed_enabled = false) does not result in an exception. Similarly, when running ALTER TABLE test SET PROPERTIES change_data_feed_enabled = false, exception should not be thrown, regardless of the value of writer_version.
There was a problem hiding this comment.
Edit: Validation of the writer_version should only be performed if the cdf is enabled.
There was a problem hiding this comment.
can we verify writer_version as well here along with change_data_feed_enabled?
b7332d5 to
05c94b8
Compare
There was a problem hiding this comment.
We can remove this. Already covered inside testCreateTableWithCdfPropertyWriterVersionNotUpgraded.
There was a problem hiding this comment.
we can include test for ALTER TABLE " + tableName + " SET PROPERTIES change_data_feed_enabled = false, writer_version = 3
05c94b8 to
777c0b3
Compare
There was a problem hiding this comment.
nit: tableName1 -> tableName
777c0b3 to
0d87b39
Compare
There was a problem hiding this comment.
| metadataEntry = Optional.of(buildMetadataEntry(session, handle, configuration, createdTime)); | |
| if (changeDataFeedEnabled && ((writerVersion.isPresent() && writerVersion.get() < CDF_SUPPORTED_WRITER_VERSION) || | |
| (currentProtocolEntry.getMinWriterVersion() < CDF_SUPPORTED_WRITER_VERSION))) { | |
| metadataEntry = Optional.of(buildMetadataEntry(session, handle, configuration, createdTime)); | |
| long newWriterVersion = writerVersion.orElse(currentProtocolEntry.getMinWriterVersion()); | |
| if (changeDataFeedEnabled && newWriterVersion < CDF_SUPPORTED_WRITER_VERSION) { |
0d87b39 to
7fd9cbd
Compare
There was a problem hiding this comment.
Move up with the other public properties
7fd9cbd to
37f9211
Compare
|
/test-with-secrets sha=37f9211dfa8fc250637eee45015afcd811ce5e90 |
...ava/io/trino/tests/product/deltalake/TestDeltaLakeDatabricksChangeDataFeedCompatibility.java
Outdated
Show resolved
Hide resolved
...ava/io/trino/tests/product/deltalake/TestDeltaLakeDatabricksChangeDataFeedCompatibility.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java
Outdated
Show resolved
Hide resolved
...ava/io/trino/tests/product/deltalake/TestDeltaLakeDatabricksChangeDataFeedCompatibility.java
Outdated
Show resolved
Hide resolved
|
The CI workflow run with tests that require additional secrets finished as failure: https://github.com/trinodb/trino/actions/runs/4288682058 |
37f9211 to
ba0dfb5
Compare
|
/test-with-secrets sha=ba0dfb55a6ac1b1601f113810b7590bfe5064362 |
ba0dfb5 to
14c03fc
Compare
14c03fc to
4371c32
Compare
We're going to increase writer version automatically.
| Optional<MetadataEntry> metadataEntry = Optional.empty(); | ||
| if (properties.containsKey(CHANGE_DATA_FEED_ENABLED_PROPERTY)) { | ||
| boolean changeDataFeedEnabled = (Boolean) properties.get(CHANGE_DATA_FEED_ENABLED_PROPERTY) | ||
| .orElseThrow(() -> new IllegalArgumentException("The change_data_feed_enabled property cannot be empty")); |
|
closing in favour of #16310 |
Description
Based on #16165
Allows setting on and off change_data_feed_enabled property
Additional context and related issues
Release notes
( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: