From aafe4797c34ecad00415691252e1a83b4207efba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Kokosi=C5=84ski?= Date: Thu, 13 Feb 2020 21:04:57 +0100 Subject: [PATCH] Return table metadata for translated Hive views --- .../src/main/java/io/prestosql/plugin/hive/HiveMetadata.java | 2 +- .../src/main/java/io/prestosql/tests/hive/TestHiveViews.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveMetadata.java b/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveMetadata.java index c998e480ab90..66e815a70d49 100644 --- a/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveMetadata.java +++ b/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveMetadata.java @@ -521,7 +521,7 @@ private ConnectorTableMetadata getTableMetadata(ConnectorSession session, Schema private ConnectorTableMetadata doGetTableMetadata(ConnectorSession session, SchemaTableName tableName) { Optional table = metastore.getTable(new HiveIdentity(session), tableName.getSchemaName(), tableName.getTableName()); - if (!table.isPresent() || isHiveOrPrestoView(table.get())) { + if (!table.isPresent() || (!translateHiveViews && isHiveOrPrestoView(table.get()))) { throw new TableNotFoundException(tableName); } diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/hive/TestHiveViews.java b/presto-product-tests/src/main/java/io/prestosql/tests/hive/TestHiveViews.java index e7bd1d810390..cf71977c9208 100644 --- a/presto-product-tests/src/main/java/io/prestosql/tests/hive/TestHiveViews.java +++ b/presto-product-tests/src/main/java/io/prestosql/tests/hive/TestHiveViews.java @@ -153,6 +153,9 @@ public void testHiveViewInInformationSchema() assertThat(query("SELECT view_definition FROM information_schema.views WHERE table_schema = 'test_schema' and table_name = 'hive_test_view'")).containsOnly( row("SELECT \"nation\".\"n_nationkey\", \"nation\".\"n_name\", \"nation\".\"n_regionkey\", \"nation\".\"n_comment\" FROM \"default\".\"nation\"")); + + assertThat(query("DESCRIBE test_schema.hive_test_view")) + .contains(row("n_nationkey", "bigint", "", "")); } @Test(groups = HIVE_VIEWS)