diff --git a/presto-hive-hadoop2/src/test/java/io/prestosql/plugin/hive/TestHive.java b/presto-hive-hadoop2/src/test/java/io/prestosql/plugin/hive/TestHive.java index fcd9b1381259..1fd8937218a1 100644 --- a/presto-hive-hadoop2/src/test/java/io/prestosql/plugin/hive/TestHive.java +++ b/presto-hive-hadoop2/src/test/java/io/prestosql/plugin/hive/TestHive.java @@ -17,6 +17,7 @@ import org.testng.SkipException; import org.testng.annotations.BeforeClass; import org.testng.annotations.Parameters; +import org.testng.annotations.Test; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; @@ -80,4 +81,16 @@ public void testHideDeltaLakeTables() throw new SkipException("not supported"); } + + @Test + public void testHiveViewTranslationError() + { + try (Transaction transaction = newTransaction()) { + assertThatThrownBy(() -> transaction.getMetadata().getView(newSession(), view)) + .isInstanceOf(HiveViewNotSupportedException.class) + .hasMessageContaining("Hive views are not supported"); + + // TODO: combine this with tests for successful translation (currently in TestHiveViews product test) + } + } } 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 aefc1bcc55d7..a268a8a2cee8 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 @@ -1919,6 +1919,10 @@ public Optional getView(ConnectorSession session, Schem return metastore.getTable(new HiveIdentity(session), viewName.getSchemaName(), viewName.getTableName()) .filter(ViewReaderUtil::canDecodeView) .map(view -> { + if (!translateHiveViews && !isPrestoView(view)) { + throw new HiveViewNotSupportedException(viewName); + } + ConnectorViewDefinition definition = createViewReader(metastore, new HiveIdentity(session), view, typeManager) .decodeViewData(view.getViewOriginalText().get(), view, catalogName); // use owner from table metadata if it exists