use of io.prestosql.metadata.TableMetadata in project hetu-core by openlookeng.
the class TableScanMatcher method detailMatches.
@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) {
checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
TableScanNode tableScanNode = (TableScanNode) node;
TableMetadata tableMetadata = metadata.getTableMetadata(session, tableScanNode.getTable());
String actualTableName = tableMetadata.getTable().getTableName();
return new MatchResult(expectedTableName.equalsIgnoreCase(actualTableName) && ((!expectedConstraint.isPresent()) || domainsMatch(expectedConstraint, tableScanNode.getEnforcedConstraint(), tableScanNode.getTable(), session, metadata)));
}
use of io.prestosql.metadata.TableMetadata in project hetu-core by openlookeng.
the class TestStarTreeAggregationRule method testDoNotUseCubeIfSourceTableUpdatedAfterCubeCreated.
@Test
public void testDoNotUseCubeIfSourceTableUpdatedAfterCubeCreated() {
Mockito.when(cubeManager.getCubeProvider(anyString())).then(new Returns(Optional.of(provider)));
Mockito.when(cubeManager.getMetaStore(anyString())).then(new Returns(Optional.of(cubeMetaStore)));
Metadata metadata = Mockito.mock(Metadata.class);
TableMetadata ordersTableMetadata = Mockito.mock(TableMetadata.class);
QualifiedObjectName objectName = new QualifiedObjectName("local", "sf1.0", "orders");
Mockito.when(metadata.getTableHandle(any(Session.class), eq(objectName))).thenReturn(Optional.of(ordersTableHandle));
Mockito.when(metadata.getTableLastModifiedTimeSupplier(any(Session.class), any(TableHandle.class))).thenReturn(() -> DateTimeUtils.parseTimestampWithoutTimeZone("2020-01-02 12:00:00"));
Mockito.when(metadata.getTableMetadata(any(Session.class), eq(ordersTableHandle))).thenReturn(ordersTableMetadata);
Mockito.when(ordersTableMetadata.getQualifiedName()).thenReturn(objectName);
List<CubeMetadata> metadataList = ImmutableList.of(cubeMetadata);
Mockito.when(cubeMetaStore.getMetadataList(eq("local.sf1.0.orders"))).then(new Returns(metadataList));
Mockito.when(cubeMetadata.matches(any(CubeStatement.class))).thenReturn(true);
Mockito.when(cubeMetadata.getLastUpdatedTime()).thenReturn(DateTimeUtils.parseTimestampWithoutTimeZone("2020-01-01 12:00:00"));
StarTreeAggregationRule starTreeAggregationRule = new StarTreeAggregationRule(cubeManager, metadata);
tester().assertThat(starTreeAggregationRule).setSystemProperty(ENABLE_STAR_TREE_INDEX, "true").on(p -> p.aggregation(builder -> builder.step(SINGLE).addAggregation(new Symbol("count_orderkey"), PlanBuilder.expression("count(orderkey)"), ImmutableList.of(BIGINT)).singleGroupingSet(new Symbol("orderdate")).source(p.project(Assignments.builder().put(p.symbol("orderdate", DATE), p.variable("orderdate", DATE)).put(p.symbol("orderkey", BIGINT), p.variable("orderkey", BIGINT)).build(), p.tableScan(ordersTableHandle, ImmutableList.of(p.symbol("orderdate", DATE), p.symbol("orderkey", BIGINT)), ImmutableMap.of(p.symbol("orderkey", BIGINT), new TpchColumnHandle("orderkey", BIGINT), p.symbol("orderdate", DATE), new TpchColumnHandle("orderdate", DATE))))))).doesNotFire();
Mockito.verify(cubeMetaStore, Mockito.atLeastOnce()).getMetadataList(eq("local.sf1.0.orders"));
Mockito.verify(cubeMetadata, Mockito.atLeastOnce()).matches(any(CubeStatement.class));
}
use of io.prestosql.metadata.TableMetadata in project hetu-core by openlookeng.
the class TableInfoSupplier method apply.
@Override
public TableInfo apply(TableScanNode node) {
TableMetadata tableMetadata = metadata.getTableMetadata(session, node.getTable());
TableProperties tableProperties = metadata.getTableProperties(session, node.getTable());
return new TableInfo(tableMetadata.getQualifiedName(), tableProperties.getPredicate());
}
use of io.prestosql.metadata.TableMetadata in project hetu-core by openlookeng.
the class TestHiveIntegrationSmokeTest method testCreatePartitionedTableAs.
private void testCreatePartitionedTableAs(Session session, HiveStorageFormat storageFormat) {
@Language("SQL") String createTable = "" + "CREATE TABLE test_create_partitioned_table_as " + "WITH (" + "format = '" + storageFormat + "', " + "partitioned_by = ARRAY[ 'SHIP_PRIORITY', 'ORDER_STATUS' ]" + ") " + "AS " + "SELECT orderkey AS order_key, shippriority AS ship_priority, orderstatus AS order_status " + "FROM tpch.tiny.orders";
assertUpdate(session, createTable, "SELECT count(*) from orders");
TableMetadata tableMetadata = getTableMetadata(catalog, TPCH_SCHEMA, "test_create_partitioned_table_as");
assertEquals(tableMetadata.getMetadata().getProperties().get(STORAGE_FORMAT_PROPERTY), storageFormat);
assertEquals(tableMetadata.getMetadata().getProperties().get(PARTITIONED_BY_PROPERTY), ImmutableList.of("ship_priority", "order_status"));
List<?> partitions = getPartitions("test_create_partitioned_table_as");
assertEquals(partitions.size(), 3);
assertQuery(session, "SELECT * from test_create_partitioned_table_as", "SELECT orderkey, shippriority, orderstatus FROM orders");
assertUpdate(session, "DROP TABLE test_create_partitioned_table_as");
assertFalse(getQueryRunner().tableExists(session, "test_create_partitioned_table_as"));
}
use of io.prestosql.metadata.TableMetadata in project hetu-core by openlookeng.
the class TestHiveIntegrationSmokeTest method testFullVacuum2.
@Test
public void testFullVacuum2() {
String table = "tab3";
String schema = "default";
assertUpdate(String.format("CREATE SCHEMA IF NOT EXISTS %s", schema));
assertUpdate(String.format("CREATE TABLE %s.%s (a int, b int) with (transactional=true, format='orc')", schema, table));
assertUpdate(String.format("INSERT INTO %s.%s VALUES (1, 2)", schema, table), 1);
assertUpdate(String.format("INSERT INTO %s.%s VALUES (3, 4)", schema, table), 1);
assertUpdate(String.format("INSERT INTO %s.%s VALUES (5, 6)", schema, table), 1);
assertUpdate(String.format("VACUUM TABLE %s.%s AND WAIT", schema, table), 3);
assertUpdate(String.format("VACUUM TABLE %s.%s FULL AND WAIT", schema, table), 3);
TableMetadata tableMetadata = getTableMetadata("hive", schema, table);
String tablePath = ((String) tableMetadata.getMetadata().getProperties().get("location"));
assertFilesAfterCleanup(tablePath, 1);
assertUpdate(String.format("DROP TABLE %s.%s", schema, table));
}
Aggregations