-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Test Delta Lake metadata handling when schema already exists #15328
Conversation
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
} | ||
|
||
@Test | ||
public void testFailWhenCreateTheSameSchemaFromTwoSessions() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testFailWhenCreateTheSameSchemaFromTwoSessions
-> testCreateSameSchemaFromDifferentSessionsFails
DeltaLakeMetadata metadata = metadataFactory.create(session.getIdentity()); | ||
|
||
metadata.createSchema(session, testSchemaName, Map.of(), TRINO_PRINCIPAL); | ||
metadata.createSchema(session, testSchemaName, Map.of(), TRINO_PRINCIPAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call metadata.schemaExists()
after the second call to be clear that the schema exists before doing the second call.
@@ -241,6 +252,37 @@ public void testHideNonDeltaLakeTable() | |||
.isEmpty(); | |||
} | |||
|
|||
@Test | |||
public void testDoubleCreateSchemaForTheSameSession() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testDoubleCreateSchemaForTheSameSession
-> testCreateSchemaTwiceInTheSameSession
String testSchemaName = "test_schema_" + randomName(); | ||
|
||
DeltaLakeMetadata metadata = metadataFactory.create(session.getIdentity()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try/finally to ensure that the Glue database does get deleted even in case of exceptions
DeltaLakeMetadata metadata = metadataFactory.create(session.getIdentity()); | ||
|
||
metadata.createSchema(session, testSchemaName, Map.of(), TRINO_PRINCIPAL); | ||
metadata.createSchema(session, testSchemaName, Map.of(), TRINO_PRINCIPAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this and the second test case shouldn't we validate that schema was actually created?
Commit message Maybe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new test I realized the issue number in the description was wrong.testDoubleCreateSchemaForTheSameSession
should fail without commits in #15177. Currently, it passes. I would recommend reverting commits temporarily when writing the test.
...-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java
Outdated
Show resolved
Hide resolved
It was mistake in description. Tests are for #13242 |
The PR isn't specific to Glue. Could you explain why this PR add tests only for Glue? |
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
1 similar comment
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Tests were in wrong place. I moved them to generic tests and changed title. |
@@ -465,6 +473,35 @@ public void testGetInputInfoForUnPartitionedTable() | |||
assertThat(deltaLakeMetadata.getInfo(tableHandle)).isEqualTo(Optional.of(new DeltaLakeInputInfo(false))); | |||
} | |||
|
|||
@Test | |||
public void testCreateSchemaTwiceInTheSameSession() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like a unit test and somebody without a context for the SchemaAlreadyExistsException
problem would have a hard time to figure out what are the tests there.
What about using a specific test - similar to TestIcebergFileMetastoreTableOperationsInsertFailure
?
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost good to me. Thanks for adding this test.
plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreate.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreate.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreate.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreate.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreate.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreate.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeMetadata.java
Outdated
Show resolved
Hide resolved
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
...lta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreateInternalRetry.java
Outdated
Show resolved
Hide resolved
...lta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreateInternalRetry.java
Outdated
Show resolved
Hide resolved
...lta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreateInternalRetry.java
Outdated
Show resolved
Hide resolved
...lta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreateInternalRetry.java
Outdated
Show resolved
Hide resolved
...lta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreateInternalRetry.java
Outdated
Show resolved
Hide resolved
...lta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSchemaCreateInternalRetry.java
Outdated
Show resolved
Hide resolved
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
@pajaks Could you fix the commit title as "Add tests for internal retry to create schema in Delta Lake"? |
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
.build(); | ||
} | ||
// Simulate retry mechanism with timeout failure. | ||
// 1. createDatabase correctly create schema but timeout is triggered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createDatabase correctly create schema but timeout is triggered
nit:
createDatabase correctly creates schema, but timeout is triggered
@Override | ||
public synchronized void createDatabase(Database database) | ||
{ | ||
if (database.getDatabaseName().equals(TEST_SCHEMA_DIFFERENT_SESSION)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this logic in a different test class to avoid mixing concerns and having the database.getDatabaseName().equals(TEST_SCHEMA_DIFFERENT_SESSION)
check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The separated test class is overkill to me.
@cla-bot check |
The cla-bot has been summoned, and re-checked this pull request! |
@pajaks Are you going to add tests for Hive as well? |
It seems like a good idea. I will look into it. |
Description
Add test for #13242 which was merged without a test as we didn't have an infrastructure for such tests at that time.
Additional context and related issues
#15282
Release notes
(x) This is not user-visible or docs only and no release notes are required.