-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Fix querying and filtering using Iceberg metadata columns #23472
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
Merged
nmahadevuni
merged 2 commits into
prestodb:master
from
nmahadevuni:fix_iceberg_info_column_filter_eval
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
...src/test/java/com/facebook/presto/nativeworker/TestPrestoNativeIcebergGeneralQueries.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.facebook.presto.nativeworker; | ||
|
|
||
| import com.facebook.presto.testing.ExpectedQueryRunner; | ||
| import com.facebook.presto.testing.QueryRunner; | ||
| import com.facebook.presto.tests.AbstractTestQueryFramework; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import static java.lang.String.format; | ||
| import static org.testng.Assert.assertEquals; | ||
|
|
||
| public class TestPrestoNativeIcebergGeneralQueries | ||
| extends AbstractTestQueryFramework | ||
| { | ||
| @Override | ||
| protected QueryRunner createQueryRunner() | ||
| throws Exception | ||
| { | ||
| return PrestoNativeQueryRunnerUtils.createNativeIcebergQueryRunner(false, true); | ||
| } | ||
|
|
||
| @Override | ||
| protected ExpectedQueryRunner createExpectedQueryRunner() | ||
| throws Exception | ||
| { | ||
| return PrestoNativeQueryRunnerUtils.createJavaIcebergQueryRunner(true); | ||
| } | ||
|
|
||
| @Override | ||
| protected void createTables() | ||
| { | ||
| createTableToTestHiddenColumns(); | ||
| } | ||
|
|
||
| private void createTableToTestHiddenColumns() | ||
| { | ||
| QueryRunner javaQueryRunner = ((QueryRunner) getExpectedQueryRunner()); | ||
| if (!javaQueryRunner.tableExists(getSession(), "test_hidden_columns")) { | ||
| javaQueryRunner.execute("CREATE TABLE test_hidden_columns AS SELECT * FROM tpch.tiny.region WHERE regionkey=0"); | ||
| javaQueryRunner.execute("INSERT INTO test_hidden_columns SELECT * FROM tpch.tiny.region WHERE regionkey=1"); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testPathHiddenColumn() | ||
|
hantangwangd marked this conversation as resolved.
|
||
| { | ||
| assertQuery("SELECT \"$path\", * FROM test_hidden_columns"); | ||
|
|
||
| // Fetch one of the file paths and use it in a filter | ||
| String filePath = (String) computeActual("SELECT \"$path\" from test_hidden_columns LIMIT 1").getOnlyValue(); | ||
| assertQuery(format("SELECT * from test_hidden_columns WHERE \"$path\"='%s'", filePath)); | ||
|
|
||
| assertEquals( | ||
| (Long) computeActual(format("SELECT count(*) from test_hidden_columns WHERE \"$path\"='%s'", filePath)) | ||
| .getOnlyValue(), | ||
| 1L); | ||
|
|
||
| // Filter for $path that doesn't exist. | ||
| assertEquals( | ||
| (Long) computeActual(format("SELECT count(*) from test_hidden_columns WHERE \"$path\"='%s'", "non-existent-path")) | ||
| .getOnlyValue(), | ||
| 0L); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDataSequenceNumberHiddenColumn() | ||
| { | ||
| assertQuery("SELECT \"$data_sequence_number\", * FROM test_hidden_columns"); | ||
|
|
||
| // Fetch one of the data sequence numbers and use it in a filter | ||
| Long dataSequenceNumber = (Long) computeActual("SELECT \"$data_sequence_number\" from test_hidden_columns LIMIT 1").getOnlyValue(); | ||
| assertQuery(format("SELECT * from test_hidden_columns WHERE \"$data_sequence_number\"=%d", dataSequenceNumber)); | ||
|
|
||
| assertEquals( | ||
| (Long) computeActual(format("SELECT count(*) from test_hidden_columns WHERE \"$data_sequence_number\"=%d", dataSequenceNumber)) | ||
| .getOnlyValue(), | ||
| 1L); | ||
|
|
||
| // Filter for $data_sequence_number that doesn't exist. | ||
| assertEquals( | ||
| (Long) computeActual(format("SELECT count(*) from test_hidden_columns WHERE \"$data_sequence_number\"=%d", 1000)) | ||
| .getOnlyValue(), | ||
| 0L); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 a test with filter not matching? For both tests