Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iceberg test improvements around time travel #13823

Conversation

findepi
Copy link
Member

@findepi findepi commented Aug 24, 2022

Extracted from #13636 where they were added thanks to @alexjo2144 's #13636 (comment)

@findepi findepi added the no-release-notes This pull request does not require release notes entry label Aug 24, 2022
@cla-bot cla-bot bot added the cla-signed label Aug 24, 2022
@findepi findepi mentioned this pull request Aug 24, 2022
Currently, the way how the system tables are implemented makes it
impossible for `getTableHandleForExecute` to be executed on a non-DATA
table, so it's just a sanity check.
@findepi findepi force-pushed the findepi/prevent-iceberg-table-procedures-on-a-snapshot-7358e5 branch from cc1e2e9 to 26a59e1 Compare August 24, 2022 10:06
Comment on lines +4497 to +4498
assertThatThrownBy(() -> query(session, "ALTER TABLE \"%s@%d\" EXECUTE OPTIMIZE".formatted(tableName, snapshotId)))
.hasMessage("Cannot execute table procedure OPTIMIZE on old snapshot " + snapshotId);
Copy link
Member

Choose a reason for hiding this comment

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

nit: How about assertQueryFails to ensure TrinoException?

Copy link
Member Author

Choose a reason for hiding this comment

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

assertThatThrownBy(() -> query(...)) is a pattern we use very widely.
if we want to deprecate it in favor of assertQueryFails, we should have a discussion about this first.

Comment on lines +4499 to +4500
assertThat(query("SELECT * FROM " + tableName))
.matches("VALUES 11, 22");
Copy link
Member

Choose a reason for hiding this comment

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

nit: No change requested. assertQuery looks better for simple query assertion.

Copy link
Member Author

Choose a reason for hiding this comment

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

agree. i think i perhaps did this more for consistency reasons.

public void testExpireSnapshotsSystemTable()
{
assertThatThrownBy(() -> query("ALTER TABLE \"nation$files\" EXECUTE EXPIRE_SNAPSHOTS"))
.hasMessage("This connector does not support table procedures");
Copy link
Member

Choose a reason for hiding this comment

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

I know it is not in the scope of this PR but I find this error message missleading for this particular case.
This connector actually supports table procedures just not on the system tables.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding io.trino.connector.system.SystemTablesMetadata#getTableHandleForExecute with a more meaningful exception message would be a solution.

@@ -5117,13 +5117,13 @@ public void testModifyingOldSnapshotIsNotPossible()
assertUpdate(format("INSERT INTO %s VALUES 4,5,6", tableName), 3);
assertQuery(sessionWithLegacySyntaxSupport, format("SELECT * FROM \"%s@%d\"", tableName, oldSnapshotId), "VALUES 1,2,3");
assertThatThrownBy(() -> query(sessionWithLegacySyntaxSupport, format("INSERT INTO \"%s@%d\" VALUES 7,8,9", tableName, oldSnapshotId)))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: There are a few more ." occurrences in the exception messages within IcebergMetadata

This could lead to unexpected state.
@findepi findepi force-pushed the findepi/prevent-iceberg-table-procedures-on-a-snapshot-7358e5 branch from 26a59e1 to defbf87 Compare August 24, 2022 18:58
@findepi findepi merged commit b487c74 into trinodb:master Aug 25, 2022
@findepi findepi deleted the findepi/prevent-iceberg-table-procedures-on-a-snapshot-7358e5 branch August 25, 2022 07:44
@github-actions github-actions bot added this to the 394 milestone Aug 25, 2022
@alexjo2144
Copy link
Member

I'm guessing ALTER TABLE ... EXECUTE ... FOR VERSION AS OF ... doesn't even parse?

@findepi
Copy link
Member Author

findepi commented Aug 26, 2022

@alexjo2144 correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed no-release-notes This pull request does not require release notes entry
Development

Successfully merging this pull request may close these issues.

5 participants