-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add handling for root bucket table location in sync_partition_metadata #20090
Add handling for root bucket table location in sync_partition_metadata #20090
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 |
@@ -191,7 +191,7 @@ private static Set<Location> listDirectories(TrinoFileSystem fileSystem, Locatio | |||
private static String listedDirectoryName(Location directory, Location location) | |||
{ | |||
String prefix = directory.path(); | |||
if (!prefix.endsWith("/")) { | |||
if (!prefix.endsWith("/") && !prefix.equals("")) { |
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.
Can we have some test coverage for this change?
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.
Thank you for comment..!
I cannot find any existing test suites for built-in procedures in Hive plugin to add some test case for this hotfix.
Did you mean creating new test module for this procedure and writing all the test cases for it..?
(Is it okay to maintain other hive procedures without test suites..?)
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.
We have so called product tests that can be used to check the accuracy of sync_partition_metadata
procedure
You can run the hdfs related product test in this way:
testing/bin/ptl test run --environment multinode -- -t io.trino.tests.product.hive.TestHdfsSyncPartitionMetadata
However, you can use for the purpose of testing your changes HiveMinioDataLake
utility.
See for example
trino/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHive3OnDataLake.java
Lines 1764 to 1785 in 33dd20a
public void testPartitionedTableExternalLocationOnTopOfTheBucket() | |
{ | |
String topBucketName = "test-hive-partitioned-top-of-the-bucket-" + randomNameSuffix(); | |
hiveMinioDataLake.getMinio().createBucket(topBucketName); | |
String tableName = "test_external_location_top_of_the_bucket_" + randomNameSuffix(); | |
assertUpdate(format( | |
"CREATE TABLE %s (" + | |
" a_varchar varchar, " + | |
" pkey integer) " + | |
"WITH (" + | |
" external_location='%s'," + | |
" partitioned_by=ARRAY['pkey'])", | |
tableName, | |
format("s3://%s/", topBucketName))); | |
assertUpdate("INSERT INTO " + tableName + " VALUES ('a', 1) , ('b', 1), ('c', 2), ('d', 2)", 4); | |
assertQuery("SELECT * FROM " + tableName, "VALUES ('a', 1), ('b',1), ('c', 2), ('d', 2)"); | |
assertUpdate("DELETE FROM " + tableName + " where pkey = 2"); | |
assertQuery("SELECT * FROM " + tableName, "VALUES ('a', 1), ('b',1)"); | |
assertUpdate("DROP TABLE " + tableName); | |
} |
Note that you can make use of io.trino.plugin.hive.containers.HiveMinioDataLake#copyResources
to copy files from the test resources to eventually simulate easier your use case.
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.
Thank you for sharing and explaining those..!
I will add some tiny test case on there!
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.
I added tiny test case following your guides :)
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.
Good job!
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 |
@@ -191,7 +191,7 @@ private static Set<Location> listDirectories(TrinoFileSystem fileSystem, Locatio | |||
private static String listedDirectoryName(Location directory, Location location) | |||
{ | |||
String prefix = directory.path(); |
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.
Update the description of your PR to point out that you're using the same strategy as in
trino/lib/trino-filesystem-s3/src/main/java/io/trino/filesystem/s3/S3FileSystem.java
Lines 175 to 177 in f7369f6
if (!key.isEmpty() && !key.endsWith("/")) { | |
key += "/"; | |
} |
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.
I haven't noticed the same strategy was already in use on another module..!
Thanks, I will update the description!
@@ -191,7 +191,7 @@ private static Set<Location> listDirectories(TrinoFileSystem fileSystem, Locatio | |||
private static String listedDirectoryName(Location directory, Location location) | |||
{ | |||
String prefix = directory.path(); | |||
if (!prefix.endsWith("/")) { | |||
if (!prefix.endsWith("/") && !prefix.equals("")) { |
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.
if (!prefix.endsWith("/") && !prefix.equals("")) { | |
if (!prefix.isEmpty() && !prefix.endsWith("/")) { |
plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHive3OnDataLake.java
Outdated
Show resolved
Hide resolved
@@ -191,7 +191,7 @@ private static Set<Location> listDirectories(TrinoFileSystem fileSystem, Locatio | |||
private static String listedDirectoryName(Location directory, Location location) | |||
{ | |||
String prefix = directory.path(); | |||
if (!prefix.endsWith("/")) { |
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.
Fix bug in sync_partition_metadata() to handle table located in the root path of s3 bucket
-> Add handling for root bucket table location in sync_partition_metadata
Commit title 80 characters. Aim for conciseness.
https://github.com/trinodb/trino/blob/master/.github/DEVELOPMENT.md#format-git-commit-messages
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.
Thanks! I am done!
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.
Squash the commits into one pls and use a concise commit title.
You can take inspiration from my previous message.
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.
I squashed commits with a message, same as the title of this PR, following your guide! Thanks!
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 |
2 similar comments
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 |
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.
LGTM % commit title
@okayhooni i see that the |
c5085e8
to
1aa1198
Compare
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 |
@findinpath |
@cla-bot check |
The cla-bot has been summoned, and re-checked this pull request! |
1aa1198
to
7f6367f
Compare
Description
sync_partition_metadata()
procedure cannot handle the table located in the root bucket path, due to bug on thelistDirectoryName()
logicRelease notes
(x) This is not user-visible or is docs only, and no release notes are required.