-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Ignore non delta lake tables on information_schema.columns queries #12122
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
findepi
merged 2 commits into
trinodb:master
from
findinpath:delta-information-schema-columns-with-hive-view
Apr 27, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
29 changes: 0 additions & 29 deletions
29
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/HideNonDeltaLakeTables.java
This file was deleted.
Oops, something went wrong.
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
125 changes: 125 additions & 0 deletions
125
...ke/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSharedHiveMetastoreWithViews.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,125 @@ | ||
| /* | ||
| * 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 io.trino.plugin.deltalake; | ||
|
|
||
| import com.google.common.collect.ImmutableMap; | ||
| import io.trino.plugin.deltalake.util.DockerizedMinioDataLake; | ||
| import io.trino.plugin.hive.TestingHivePlugin; | ||
| import io.trino.testing.AbstractTestQueryFramework; | ||
| import io.trino.testing.DistributedQueryRunner; | ||
| import io.trino.testing.QueryRunner; | ||
| import org.testng.annotations.AfterClass; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.Optional; | ||
|
|
||
| import static io.trino.plugin.deltalake.DeltaLakeDockerizedMinioDataLake.createDockerizedMinioDataLakeForDeltaLake; | ||
| import static io.trino.plugin.deltalake.util.MinioContainer.MINIO_ACCESS_KEY; | ||
| import static io.trino.plugin.deltalake.util.MinioContainer.MINIO_SECRET_KEY; | ||
| import static io.trino.testing.sql.TestTable.randomTableSuffix; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
|
||
| public class TestDeltaLakeSharedHiveMetastoreWithViews | ||
findinpath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| extends AbstractTestQueryFramework | ||
| { | ||
| protected final String schema = "test_shared_schema_with_hive_views_" + randomTableSuffix(); | ||
| private final String bucketName = "delta-lake-shared-hive-with-views-" + randomTableSuffix(); | ||
|
|
||
| private DockerizedMinioDataLake dockerizedMinioDataLake; | ||
|
|
||
| @Override | ||
| protected QueryRunner createQueryRunner() | ||
| throws Exception | ||
| { | ||
| this.dockerizedMinioDataLake = closeAfterClass(createDockerizedMinioDataLakeForDeltaLake(bucketName, Optional.empty())); | ||
|
|
||
| DistributedQueryRunner queryRunner = DeltaLakeQueryRunner.createS3DeltaLakeQueryRunner( | ||
| "delta", | ||
| schema, | ||
| ImmutableMap.<String, String>builder() | ||
| .put("delta.enable-non-concurrent-writes", "true") | ||
| .buildOrThrow(), | ||
| dockerizedMinioDataLake.getMinioAddress(), | ||
| dockerizedMinioDataLake.getTestingHadoop()); | ||
| queryRunner.execute("CREATE SCHEMA " + schema + " WITH (location = 's3://" + bucketName + "/" + schema + "')"); | ||
|
|
||
| queryRunner.installPlugin(new TestingHivePlugin()); | ||
| Map<String, String> s3Properties = ImmutableMap.<String, String>builder() | ||
| .put("hive.s3.aws-access-key", MINIO_ACCESS_KEY) | ||
| .put("hive.s3.aws-secret-key", MINIO_SECRET_KEY) | ||
| .put("hive.s3.endpoint", dockerizedMinioDataLake.getMinioAddress()) | ||
| .put("hive.s3.path-style-access", "true") | ||
| .buildOrThrow(); | ||
| queryRunner.createCatalog( | ||
| "hive", | ||
| "hive", | ||
| ImmutableMap.<String, String>builder() | ||
| .put("hive.metastore.uri", dockerizedMinioDataLake.getTestingHadoop().getMetastoreAddress()) | ||
| .put("hive.allow-drop-table", "true") | ||
| .putAll(s3Properties) | ||
| .buildOrThrow()); | ||
|
|
||
| queryRunner.execute("CREATE TABLE hive." + schema + ".hive_table (a_integer integer)"); | ||
| dockerizedMinioDataLake.getTestingHadoop().runOnHive("CREATE VIEW " + schema + ".hive_view AS SELECT * FROM " + schema + ".hive_table"); | ||
| queryRunner.execute("CREATE TABLE delta." + schema + ".delta_table (a_varchar varchar)"); | ||
|
|
||
| return queryRunner; | ||
| } | ||
|
|
||
| @AfterClass(alwaysRun = true) | ||
| public void cleanup() | ||
| { | ||
| assertQuerySucceeds("DROP TABLE IF EXISTS hive." + schema + ".hive_table"); | ||
| dockerizedMinioDataLake.getTestingHadoop().runOnHive("DROP VIEW IF EXISTS " + schema + ".hive_view"); | ||
| assertQuerySucceeds("DROP TABLE IF EXISTS delta." + schema + ".delta_table"); | ||
| assertQuerySucceeds("DROP SCHEMA IF EXISTS hive." + schema); | ||
| } | ||
|
|
||
| @Test | ||
| public void testReadInformationSchema() | ||
| { | ||
| assertThat(query("SELECT table_schema FROM hive.information_schema.tables WHERE table_name = 'hive_table' AND table_schema='" + schema + "'")) | ||
| .skippingTypesCheck() | ||
| .containsAll("VALUES '" + schema + "'"); | ||
| assertThat(query("SELECT table_schema FROM delta.information_schema.tables WHERE table_name = 'delta_table' AND table_schema='" + schema + "'")) | ||
| .skippingTypesCheck() | ||
| .containsAll("VALUES '" + schema + "'"); | ||
|
|
||
| assertQuery("SELECT table_name, column_name from hive.information_schema.columns WHERE table_schema = '" + schema + "'", | ||
| "VALUES ('hive_table', 'a_integer')"); | ||
| assertQuery("SELECT table_name, column_name from delta.information_schema.columns WHERE table_schema = '" + schema + "'", | ||
| "VALUES ('delta_table', 'a_varchar')"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testShowTables() | ||
| { | ||
| assertQuery("SHOW TABLES FROM delta." + schema, "VALUES 'hive_table', 'hive_view', 'delta_table'"); | ||
| assertQuery("SHOW TABLES FROM hive." + schema, "VALUES 'hive_table', 'hive_view', 'delta_table'"); | ||
|
|
||
| assertThatThrownBy(() -> query("SHOW CREATE TABLE delta." + schema + ".hive_table")) | ||
| .hasMessageContaining("not a Delta Lake table"); | ||
| assertThatThrownBy(() -> query("SHOW CREATE TABLE delta." + schema + ".hive_view")) | ||
| .hasMessageContaining("not a Delta Lake table"); | ||
| assertThatThrownBy(() -> query("SHOW CREATE TABLE hive." + schema + ".delta_table")) | ||
| .hasMessageContaining("Cannot query Delta Lake table"); | ||
|
|
||
| assertThatThrownBy(() -> query("DESCRIBE delta." + schema + ".hive_table")) | ||
| .hasMessageContaining("not a Delta Lake table"); | ||
| assertThatThrownBy(() -> query("DESCRIBE hive." + schema + ".delta_table")) | ||
| .hasMessageContaining("Cannot query Delta Lake table"); | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.