Skip to content

Commit

Permalink
Enforce hive.translate-hive-views propertry
Browse files Browse the repository at this point in the history
  • Loading branch information
phd3 authored and martint committed Oct 23, 2020
1 parent ad7baad commit a4d2c58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,10 @@ public Optional<ConnectorViewDefinition> 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
Expand Down

0 comments on commit a4d2c58

Please sign in to comment.