use of io.trino.connector.MockConnectorEntities.TPCH_WITH_HIDDEN_COLUMN_DATA in project trino by trinodb.
the class TestColumnMask method init.
@BeforeAll
public void init() {
LocalQueryRunner runner = LocalQueryRunner.builder(SESSION).build();
runner.createCatalog(CATALOG, new TpchConnectorFactory(1), ImmutableMap.of());
ConnectorViewDefinition view = new ConnectorViewDefinition("SELECT nationkey, name FROM local.tiny.nation", Optional.empty(), Optional.empty(), ImmutableList.of(new ConnectorViewDefinition.ViewColumn("nationkey", BigintType.BIGINT.getTypeId()), new ConnectorViewDefinition.ViewColumn("name", VarcharType.createVarcharType(25).getTypeId())), Optional.empty(), Optional.of(VIEW_OWNER), false);
ConnectorMaterializedViewDefinition materializedView = new ConnectorMaterializedViewDefinition("SELECT * FROM local.tiny.nation", Optional.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(new ConnectorMaterializedViewDefinition.Column("nationkey", BigintType.BIGINT.getTypeId()), new ConnectorMaterializedViewDefinition.Column("name", VarcharType.createVarcharType(25).getTypeId()), new ConnectorMaterializedViewDefinition.Column("regionkey", BigintType.BIGINT.getTypeId()), new ConnectorMaterializedViewDefinition.Column("comment", VarcharType.createVarcharType(152).getTypeId())), Optional.empty(), Optional.of(VIEW_OWNER), ImmutableMap.of());
ConnectorMaterializedViewDefinition freshMaterializedView = new ConnectorMaterializedViewDefinition("SELECT * FROM local.tiny.nation", Optional.of(new CatalogSchemaTableName("local", "tiny", "nation")), Optional.empty(), Optional.empty(), ImmutableList.of(new ConnectorMaterializedViewDefinition.Column("nationkey", BigintType.BIGINT.getTypeId()), new ConnectorMaterializedViewDefinition.Column("name", VarcharType.createVarcharType(25).getTypeId()), new ConnectorMaterializedViewDefinition.Column("regionkey", BigintType.BIGINT.getTypeId()), new ConnectorMaterializedViewDefinition.Column("comment", VarcharType.createVarcharType(152).getTypeId())), Optional.empty(), Optional.of(VIEW_OWNER), ImmutableMap.of());
ConnectorMaterializedViewDefinition materializedViewWithCasts = new ConnectorMaterializedViewDefinition("SELECT nationkey, cast(name as varchar(1)) as name, regionkey, comment FROM local.tiny.nation", Optional.of(new CatalogSchemaTableName("local", "tiny", "nation")), Optional.empty(), Optional.empty(), ImmutableList.of(new ConnectorMaterializedViewDefinition.Column("nationkey", BigintType.BIGINT.getTypeId()), new ConnectorMaterializedViewDefinition.Column("name", VarcharType.createVarcharType(2).getTypeId()), new ConnectorMaterializedViewDefinition.Column("regionkey", BigintType.BIGINT.getTypeId()), new ConnectorMaterializedViewDefinition.Column("comment", VarcharType.createVarcharType(152).getTypeId())), Optional.empty(), Optional.of(VIEW_OWNER), ImmutableMap.of());
MockConnectorFactory mock = MockConnectorFactory.builder().withGetColumns(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_hidden_column"))) {
return TPCH_NATION_WITH_HIDDEN_COLUMN;
}
throw new UnsupportedOperationException();
}).withData(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_hidden_column"))) {
return TPCH_WITH_HIDDEN_COLUMN_DATA;
}
throw new UnsupportedOperationException();
}).withGetViews((s, prefix) -> ImmutableMap.of(new SchemaTableName("default", "nation_view"), view)).withGetMaterializedViews((s, prefix) -> ImmutableMap.of(new SchemaTableName("default", "nation_materialized_view"), materializedView, new SchemaTableName("default", "nation_fresh_materialized_view"), freshMaterializedView, new SchemaTableName("default", "materialized_view_with_casts"), materializedViewWithCasts)).build();
runner.createCatalog(MOCK_CATALOG, mock, ImmutableMap.of());
assertions = new QueryAssertions(runner);
accessControl = assertions.getQueryRunner().getAccessControl();
}
use of io.trino.connector.MockConnectorEntities.TPCH_WITH_HIDDEN_COLUMN_DATA in project trino by trinodb.
the class TestRowFilter method init.
@BeforeAll
public void init() {
LocalQueryRunner runner = LocalQueryRunner.builder(SESSION).build();
runner.createCatalog(CATALOG, new TpchConnectorFactory(1), ImmutableMap.of());
ConnectorViewDefinition view = new ConnectorViewDefinition("SELECT nationkey, name FROM local.tiny.nation", Optional.empty(), Optional.empty(), ImmutableList.of(new ConnectorViewDefinition.ViewColumn("nationkey", BigintType.BIGINT.getTypeId()), new ConnectorViewDefinition.ViewColumn("name", VarcharType.createVarcharType(25).getTypeId())), Optional.empty(), Optional.of(VIEW_OWNER), false);
MockConnectorFactory mock = MockConnectorFactory.builder().withGetViews((s, prefix) -> ImmutableMap.<SchemaTableName, ConnectorViewDefinition>builder().put(new SchemaTableName("default", "nation_view"), view).buildOrThrow()).withGetColumns(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("tiny", "nation"))) {
return TPCH_NATION_SCHEMA;
}
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_hidden_column"))) {
return TPCH_NATION_WITH_HIDDEN_COLUMN;
}
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
return TPCH_NATION_WITH_OPTIONAL_COLUMN;
}
throw new UnsupportedOperationException();
}).withData(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("tiny", "nation"))) {
return TPCH_NATION_DATA;
}
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_hidden_column"))) {
return TPCH_WITH_HIDDEN_COLUMN_DATA;
}
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
return TPCH_NATION_DATA;
}
throw new UnsupportedOperationException();
}).build();
runner.createCatalog(MOCK_CATALOG, mock, ImmutableMap.of());
MockConnectorFactory mockMissingColumns = MockConnectorFactory.builder().withName("mockmissingcolumns").withGetViews((s, prefix) -> ImmutableMap.<SchemaTableName, ConnectorViewDefinition>builder().put(new SchemaTableName("default", "nation_view"), view).buildOrThrow()).withGetColumns(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
return TPCH_NATION_WITH_OPTIONAL_COLUMN;
}
throw new UnsupportedOperationException();
}).withData(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
return TPCH_NATION_DATA;
}
throw new UnsupportedOperationException();
}).withAllowMissingColumnsOnInsert(true).build();
runner.createCatalog(MOCK_CATALOG_MISSING_COLUMNS, mockMissingColumns, ImmutableMap.of());
assertions = new QueryAssertions(runner);
accessControl = assertions.getQueryRunner().getAccessControl();
}
Aggregations