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

Test Delta Lake metadata handling when schema already exists #15328

Merged
merged 1 commit into from
Dec 20, 2022
Merged

Test Delta Lake metadata handling when schema already exists #15328

merged 1 commit into from
Dec 20, 2022

Conversation

pajaks
Copy link
Member

@pajaks pajaks commented Dec 7, 2022

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.

@cla-bot
Copy link

cla-bot bot commented Dec 7, 2022

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()
Copy link
Contributor

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);
Copy link
Contributor

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()
Copy link
Contributor

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());

Copy link
Contributor

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);
Copy link
Member

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?

@findinpath
Copy link
Contributor

Commit message Add tests for creating schema

Maybe Test Delta AWS Glue handling when schema already exists

@ebyhr ebyhr changed the title Add tests for creating schema Test Delta AWS Glue handling when schema already exists Dec 8, 2022
Copy link
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

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

The new test testDoubleCreateSchemaForTheSameSession should fail without commits in #15177. Currently, it passes. I would recommend reverting commits temporarily when writing the test. I realized the issue number in the description was wrong.

@pajaks
Copy link
Member Author

pajaks commented Dec 8, 2022

It was mistake in description. Tests are for #13242

@ebyhr
Copy link
Member

ebyhr commented Dec 8, 2022

Tests are for #13242

The PR isn't specific to Glue. Could you explain why this PR add tests only for Glue?

@cla-bot
Copy link

cla-bot bot commented Dec 8, 2022

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
@cla-bot
Copy link

cla-bot bot commented Dec 9, 2022

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 pajaks changed the title Test Delta AWS Glue handling when schema already exists Test Delta Lake metadata handling when schema already exists Dec 9, 2022
@pajaks
Copy link
Member Author

pajaks commented Dec 9, 2022

Tests are for #13242

The PR isn't specific to Glue. Could you explain why this PR add tests only for Glue?

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()
Copy link
Contributor

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 ?

@cla-bot
Copy link

cla-bot bot commented Dec 12, 2022

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

Copy link
Member

@ebyhr ebyhr left a 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.

@cla-bot
Copy link

cla-bot bot commented Dec 13, 2022

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

@cla-bot
Copy link

cla-bot bot commented Dec 13, 2022

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

@ebyhr
Copy link
Member

ebyhr commented Dec 14, 2022

Add tests for creating schema

@pajaks Could you fix the commit title as "Add tests for internal retry to create schema in Delta Lake"?

@cla-bot
Copy link

cla-bot bot commented Dec 14, 2022

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
Copy link
Contributor

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)) {
Copy link
Contributor

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

Copy link
Member

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.

@ebyhr
Copy link
Member

ebyhr commented Dec 20, 2022

@cla-bot check

@cla-bot cla-bot bot added the cla-signed label Dec 20, 2022
@cla-bot
Copy link

cla-bot bot commented Dec 20, 2022

The cla-bot has been summoned, and re-checked this pull request!

@ebyhr ebyhr merged commit f1e7ba2 into trinodb:master Dec 20, 2022
@github-actions github-actions bot added this to the 404 milestone Dec 20, 2022
@ebyhr
Copy link
Member

ebyhr commented Dec 21, 2022

@pajaks Are you going to add tests for Hive as well?

@pajaks
Copy link
Member Author

pajaks commented Dec 21, 2022

@pajaks Are you going to add tests for Hive as well?

It seems like a good idea. I will look into it.

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

Successfully merging this pull request may close these issues.

4 participants