use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestHiveMaterializedViewUtils method testDifferenceDataPredicatesEmptyDataPredicates.
@Test
public void testDifferenceDataPredicatesEmptyDataPredicates() {
TestingTypeManager typeManager = new TestingTypeManager();
TestingSemiTransactionalHiveMetastore testMetastore = TestingSemiTransactionalHiveMetastore.create();
Column dsColumn = new Column("ds", HIVE_STRING, Optional.empty(), Optional.empty());
Column shipmodeColumn = new Column("shipmode", HIVE_STRING, Optional.empty(), Optional.empty());
List<Column> partitionColumns = ImmutableList.of(dsColumn, shipmodeColumn);
List<String> partitions = ImmutableList.of("ds=2020-01-01/shipmode=air", "ds=2020-01-01/shipmode=road");
testMetastore.setPartitionNames(partitions);
MaterializedDataPredicates baseDataPredicates = getMaterializedDataPredicates(testMetastore, metastoreContext, typeManager, getTable(partitionColumns), DateTimeZone.UTC);
Column viewShipModeColumn = new Column("view_shipmode", HIVE_STRING, Optional.empty(), Optional.empty());
List<Column> viewPartitionColumns = ImmutableList.of(dsColumn, viewShipModeColumn);
List<String> viewPartitions = ImmutableList.of();
testMetastore.setPartitionNames(viewPartitions);
MaterializedDataPredicates materializedDataPredicates = getMaterializedDataPredicates(testMetastore, metastoreContext, typeManager, getTable(viewPartitionColumns), DateTimeZone.UTC);
Map<String, String> materializedViewToBaseColumnMap = ImmutableMap.of();
ImmutableList.Builder<List<TestingPartitionResult>> partitionResults = ImmutableList.builder();
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-01' AS varchar)"), new TestingPartitionResult("shipmode", VARCHAR, "CAST('air' AS varchar)")));
MaterializedDataPredicates diffDataPredicates = differenceDataPredicates(baseDataPredicates, materializedDataPredicates, materializedViewToBaseColumnMap);
assertEquals(diffDataPredicates, getEmptyMaterializedViewDataPredicates());
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestHiveMaterializedViewUtils method testMaterializedDataPredicatesWithNullPartitions.
@Test
public void testMaterializedDataPredicatesWithNullPartitions() {
TestingTypeManager typeManager = new TestingTypeManager();
TestingSemiTransactionalHiveMetastore testMetastore = TestingSemiTransactionalHiveMetastore.create();
List<String> keys = ImmutableList.of("ds", "category");
Column dsColumn = new Column("ds", HIVE_STRING, Optional.empty(), Optional.empty());
Column categoryColumn = new Column("category", HIVE_STRING, Optional.empty(), Optional.empty());
List<Column> partitionColumns = ImmutableList.of(dsColumn, categoryColumn);
List<String> partitions = ImmutableList.of("ds=2020-01-01/category=c1", "ds=2020-01-01/category=" + HIVE_DEFAULT_DYNAMIC_PARTITION, "ds=2020-01-02/category=c1", "ds=" + HIVE_DEFAULT_DYNAMIC_PARTITION + "/category=c2");
testMetastore.setPartitionNames(partitions);
ImmutableList.Builder<List<TestingPartitionResult>> partitionResults = ImmutableList.builder();
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-01' AS varchar)"), new TestingPartitionResult("category", VARCHAR, "CAST('c1' AS varchar)")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-01' AS varchar)"), new TestingPartitionResult("category", VARCHAR, "CAST(null AS varchar)")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-02' AS varchar)"), new TestingPartitionResult("category", VARCHAR, "CAST('c1' AS varchar)")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST(null AS varchar)"), new TestingPartitionResult("category", VARCHAR, "CAST('c2' AS varchar)")));
MaterializedDataPredicates materializedDataPredicates = getMaterializedDataPredicates(testMetastore, metastoreContext, typeManager, getTable(partitionColumns), DateTimeZone.UTC);
comparePredicates(materializedDataPredicates, keys, partitionResults.build());
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestHiveMaterializedViewUtils method testDifferenceDataPredicatesFullyMaterialized.
@Test
public void testDifferenceDataPredicatesFullyMaterialized() {
TestingTypeManager typeManager = new TestingTypeManager();
TestingSemiTransactionalHiveMetastore testMetastore = TestingSemiTransactionalHiveMetastore.create();
List<String> keys = ImmutableList.of("ds", "shipmode");
Column dsColumn = new Column("ds", HIVE_STRING, Optional.empty(), Optional.empty());
Column shipmodeColumn = new Column("shipmode", HIVE_STRING, Optional.empty(), Optional.empty());
List<Column> partitionColumns = ImmutableList.of(dsColumn, shipmodeColumn);
List<String> partitions = ImmutableList.of("ds=2020-01-01/shipmode=air", "ds=2020-01-01/shipmode=road", "ds=2020-01-02/shipmode=air", "ds=2020-01-02/shipmode=road");
testMetastore.setPartitionNames(partitions);
MaterializedDataPredicates baseDataPredicates = getMaterializedDataPredicates(testMetastore, metastoreContext, typeManager, getTable(partitionColumns), DateTimeZone.UTC);
Column viewShipModeColumn = new Column("view_shipmode", HIVE_STRING, Optional.empty(), Optional.empty());
List<Column> viewPartitionColumns = ImmutableList.of(dsColumn, viewShipModeColumn);
List<String> viewPartitions = ImmutableList.of("ds=2020-01-01/view_shipmode=air", "ds=2020-01-01/view_shipmode=road", "ds=2020-01-02/view_shipmode=air", "ds=2020-01-02/view_shipmode=road");
testMetastore.setPartitionNames(viewPartitions);
MaterializedDataPredicates materializedDataPredicates = getMaterializedDataPredicates(testMetastore, metastoreContext, typeManager, getTable(viewPartitionColumns), DateTimeZone.UTC);
Map<String, String> materializedViewToBaseColumnMap = ImmutableMap.of("ds", "ds", "view_shipmode", "shipmode");
ImmutableList.Builder<List<TestingPartitionResult>> partitionResults = ImmutableList.builder();
MaterializedDataPredicates diffDataPredicates = differenceDataPredicates(baseDataPredicates, materializedDataPredicates, materializedViewToBaseColumnMap);
comparePredicates(diffDataPredicates, keys, partitionResults.build());
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestHiveMaterializedViewUtils method testMaterializedDataPredicates.
@Test
public void testMaterializedDataPredicates() {
TestingTypeManager typeManager = new TestingTypeManager();
TestingSemiTransactionalHiveMetastore testMetastore = TestingSemiTransactionalHiveMetastore.create();
List<String> keys = ImmutableList.of("ds", "category");
Column dsColumn = new Column("ds", HIVE_STRING, Optional.empty(), Optional.empty());
Column categoryColumn = new Column("category", HIVE_STRING, Optional.empty(), Optional.empty());
List<Column> partitionColumns = ImmutableList.of(dsColumn, categoryColumn);
List<String> partitions = ImmutableList.of("ds=2020-01-01/category=c1", "ds=2020-01-01/category=c2", "ds=2020-01-02/category=c1", "ds=2020-01-02/category=c2");
testMetastore.setPartitionNames(partitions);
ImmutableList.Builder<List<TestingPartitionResult>> partitionResults = ImmutableList.builder();
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-01' AS varchar)"), new TestingPartitionResult("category", VARCHAR, "CAST('c1' AS varchar)")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-01' AS varchar)"), new TestingPartitionResult("category", VARCHAR, "CAST('c2' AS varchar)")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-02' AS varchar)"), new TestingPartitionResult("category", VARCHAR, "CAST('c1' AS varchar)")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-02' AS varchar)"), new TestingPartitionResult("category", VARCHAR, "CAST('c2' AS varchar)")));
MaterializedDataPredicates materializedDataPredicates = getMaterializedDataPredicates(testMetastore, metastoreContext, typeManager, getTable(partitionColumns), DateTimeZone.UTC);
comparePredicates(materializedDataPredicates, keys, partitionResults.build());
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestHiveMaterializedViewUtils method testDifferenceDataOuterJoin.
@Test
public void testDifferenceDataOuterJoin() {
TestingTypeManager typeManager = new TestingTypeManager();
TestingSemiTransactionalHiveMetastore testMetastore = TestingSemiTransactionalHiveMetastore.create();
List<String> keys = ImmutableList.of("ds");
Column dsColumn = new Column("ds", HIVE_STRING, Optional.empty(), Optional.empty());
List<Column> partitionColumns = ImmutableList.of(dsColumn);
List<String> partitions = ImmutableList.of("ds=2020-01-01", "ds=2020-01-02", "ds=2020-01-03", "ds=2020-01-04", "ds=2020-01-05", "ds=2020-01-06");
testMetastore.setPartitionNames(partitions);
MaterializedDataPredicates baseDataPredicates = getMaterializedDataPredicates(testMetastore, metastoreContext, typeManager, getTable(partitionColumns), DateTimeZone.UTC);
// CREATE MV AS SELECT ds1 as t1.ds, ds2 as t2.ds FROM t1 LEFT JOIN t2 ON t1.ds = t2.ds
List<String> viewPartitions = ImmutableList.of("ds1=2020-01-02/ds2=2020-01-02", "ds1=2020-01-03/ds2=null", "ds1=2020-01-05/ds2=null", "ds1=2020-01-05/ds2=2020-01-05");
List<Column> viewPartitionColumns = ImmutableList.of(new Column("ds1", HIVE_STRING, Optional.empty(), Optional.empty()), new Column("ds2", HIVE_STRING, Optional.empty(), Optional.empty()));
testMetastore.setPartitionNames(viewPartitions);
MaterializedDataPredicates materializedDataPredicates = getMaterializedDataPredicates(testMetastore, metastoreContext, typeManager, getTable(viewPartitionColumns), DateTimeZone.UTC);
Map<String, String> materializedViewToBaseColumnMap = ImmutableMap.of("ds2", "ds");
ImmutableList.Builder<List<TestingPartitionResult>> partitionResults = ImmutableList.builder();
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-01' AS varchar)")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-04' AS varchar)")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-06' AS varchar)")));
MaterializedDataPredicates diffDataPredicates = differenceDataPredicates(baseDataPredicates, materializedDataPredicates, materializedViewToBaseColumnMap, ImmutableMap.of("ds1", "ds"));
comparePredicates(diffDataPredicates, keys, partitionResults.build());
}
Aggregations