use of io.prestosql.metadata.Metadata in project hetu-core by openlookeng.
the class TestFilterStatsCalculator method setUp.
@BeforeClass
public void setUp() {
xStats = SymbolStatsEstimate.builder().setAverageRowSize(4.0).setDistinctValuesCount(40.0).setLowValue(-10.0).setHighValue(10.0).setNullsFraction(0.25).build();
yStats = SymbolStatsEstimate.builder().setAverageRowSize(4.0).setDistinctValuesCount(20.0).setLowValue(0.0).setHighValue(5.0).setNullsFraction(0.5).build();
zStats = SymbolStatsEstimate.builder().setAverageRowSize(4.0).setDistinctValuesCount(5.0).setLowValue(-100.0).setHighValue(100.0).setNullsFraction(0.1).build();
leftOpenStats = SymbolStatsEstimate.builder().setAverageRowSize(4.0).setDistinctValuesCount(50.0).setLowValue(NEGATIVE_INFINITY).setHighValue(15.0).setNullsFraction(0.1).build();
rightOpenStats = SymbolStatsEstimate.builder().setAverageRowSize(4.0).setDistinctValuesCount(50.0).setLowValue(-15.0).setHighValue(POSITIVE_INFINITY).setNullsFraction(0.1).build();
unknownRangeStats = SymbolStatsEstimate.builder().setAverageRowSize(4.0).setDistinctValuesCount(50.0).setLowValue(NEGATIVE_INFINITY).setHighValue(POSITIVE_INFINITY).setNullsFraction(0.1).build();
emptyRangeStats = SymbolStatsEstimate.builder().setAverageRowSize(0.0).setDistinctValuesCount(0.0).setLowValue(NaN).setHighValue(NaN).setNullsFraction(NaN).build();
mediumVarcharStats = SymbolStatsEstimate.builder().setAverageRowSize(85.0).setDistinctValuesCount(165).setLowValue(NEGATIVE_INFINITY).setHighValue(POSITIVE_INFINITY).setNullsFraction(0.34).build();
standardInputStatistics = PlanNodeStatsEstimate.builder().addSymbolStatistics(new Symbol("x"), xStats).addSymbolStatistics(new Symbol("y"), yStats).addSymbolStatistics(new Symbol("z"), zStats).addSymbolStatistics(new Symbol("leftOpen"), leftOpenStats).addSymbolStatistics(new Symbol("rightOpen"), rightOpenStats).addSymbolStatistics(new Symbol("unknownRange"), unknownRangeStats).addSymbolStatistics(new Symbol("emptyRange"), emptyRangeStats).addSymbolStatistics(new Symbol("mediumVarchar"), mediumVarcharStats).setOutputRowCount(1000.0).build();
standardTypes = TypeProvider.copyOf(ImmutableMap.<Symbol, Type>builder().put(new Symbol("x"), DoubleType.DOUBLE).put(new Symbol("y"), DoubleType.DOUBLE).put(new Symbol("z"), DoubleType.DOUBLE).put(new Symbol("leftOpen"), DoubleType.DOUBLE).put(new Symbol("rightOpen"), DoubleType.DOUBLE).put(new Symbol("unknownRange"), DoubleType.DOUBLE).put(new Symbol("emptyRange"), DoubleType.DOUBLE).put(new Symbol("mediumVarchar"), MEDIUM_VARCHAR_TYPE).build());
session = testSessionBuilder().build();
Metadata metadata = createTestMetadataManager();
statsCalculator = new FilterStatsCalculator(metadata, new ScalarStatsCalculator(metadata), new StatsNormalizer());
}
use of io.prestosql.metadata.Metadata in project hetu-core by openlookeng.
the class TestAccessControlManager method registerBogusConnector.
private static CatalogName registerBogusConnector(CatalogManager catalogManager, TransactionManager transactionManager, AccessControl accessControl, String catalogName) {
CatalogName catalog = new CatalogName(catalogName);
Connector connector = new TpchConnectorFactory().create(catalogName, ImmutableMap.of(), new TestingConnectorContext());
InMemoryNodeManager nodeManager = new InMemoryNodeManager();
Metadata metadata = createTestMetadataManager(catalogManager);
CatalogName systemId = createSystemTablesCatalogName(catalog);
catalogManager.registerCatalog(new Catalog(catalogName, catalog, connector, createInformationSchemaCatalogName(catalog), new InformationSchemaConnector(catalogName, nodeManager, metadata, accessControl), systemId, new SystemConnector(nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, catalog))));
return catalog;
}
use of io.prestosql.metadata.Metadata in project hetu-core by openlookeng.
the class TestUnnestOperator method testUnnestWithArray.
@Test
public void testUnnestWithArray() {
Metadata metadata = createTestMetadataManager();
Type arrayType = metadata.getType(parseTypeSignature("array(array(bigint))"));
Type mapType = metadata.getType(parseTypeSignature("map(array(bigint),array(bigint))"));
List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType).row(1L, arrayBlockOf(new ArrayType(BIGINT), ImmutableList.of(2, 4), ImmutableList.of(3, 6)), mapBlockOf(new ArrayType(BIGINT), new ArrayType(BIGINT), ImmutableMap.of(ImmutableList.of(4, 8), ImmutableList.of(5, 10)))).row(2L, arrayBlockOf(new ArrayType(BIGINT), ImmutableList.of(99, 198)), null).row(3L, null, null).pageBreak().row(6, arrayBlockOf(new ArrayType(BIGINT), ImmutableList.of(7, 14), ImmutableList.of(8, 16)), mapBlockOf(new ArrayType(BIGINT), new ArrayType(BIGINT), ImmutableMap.of(ImmutableList.of(9, 18), ImmutableList.of(10, 20), ImmutableList.of(11, 22), ImmutableList.of(12, 24)))).build();
OperatorFactory operatorFactory = new UnnestOperator.UnnestOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(0), ImmutableList.of(BIGINT), ImmutableList.of(1, 2), ImmutableList.of(arrayType, mapType), false);
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, new ArrayType(BIGINT), new ArrayType(BIGINT), new ArrayType(BIGINT)).row(1L, ImmutableList.of(2L, 4L), ImmutableList.of(4L, 8L), ImmutableList.of(5L, 10L)).row(1L, ImmutableList.of(3L, 6L), null, null).row(2L, ImmutableList.of(99L, 198L), null, null).row(6L, ImmutableList.of(7L, 14L), ImmutableList.of(9L, 18L), ImmutableList.of(10L, 20L)).row(6L, ImmutableList.of(8L, 16L), ImmutableList.of(11L, 22L), ImmutableList.of(12L, 24L)).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
use of io.prestosql.metadata.Metadata in project hetu-core by openlookeng.
the class TestUnnestOperator method testUnnestWithOrdinality.
@Test
public void testUnnestWithOrdinality() {
Metadata metadata = createTestMetadataManager();
Type arrayType = metadata.getType(parseTypeSignature("array(bigint)"));
Type mapType = metadata.getType(parseTypeSignature("map(bigint,bigint)"));
List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType).row(1L, arrayBlockOf(BIGINT, 2, 3), mapBlockOf(BIGINT, BIGINT, ImmutableMap.of(4, 5))).row(2L, arrayBlockOf(BIGINT, 99), null).row(3L, null, null).pageBreak().row(6L, arrayBlockOf(BIGINT, 7, 8), mapBlockOf(BIGINT, BIGINT, ImmutableMap.of(9, 10, 11, 12))).build();
OperatorFactory operatorFactory = new UnnestOperator.UnnestOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(0), ImmutableList.of(BIGINT), ImmutableList.of(1, 2), ImmutableList.of(arrayType, mapType), true);
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, BIGINT, BIGINT, BIGINT, BIGINT).row(1L, 2L, 4L, 5L, 1L).row(1L, 3L, null, null, 2L).row(2L, 99L, null, null, 1L).row(6L, 7L, 9L, 10L, 1L).row(6L, 8L, 11L, 12L, 2L).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
use of io.prestosql.metadata.Metadata in project hetu-core by openlookeng.
the class TestUnnestOperator method testUnnestWithArrayOfRows.
@Test
public void testUnnestWithArrayOfRows() {
Metadata metadata = createTestMetadataManager();
Type arrayOfRowType = metadata.getType(parseTypeSignature("array(row(bigint, double, varchar))"));
Type elementType = RowType.anonymous(ImmutableList.of(BIGINT, DOUBLE, VARCHAR));
List<Page> input = rowPagesBuilder(BIGINT, arrayOfRowType).row(1, arrayBlockOf(elementType, ImmutableList.of(2, 4.2, "abc"), ImmutableList.of(3, 6.6, "def"))).row(2, arrayBlockOf(elementType, ImmutableList.of(99, 3.14, "pi"), null)).row(3, null).pageBreak().row(6, arrayBlockOf(elementType, null, ImmutableList.of(8, 1.111, "tt"))).build();
OperatorFactory operatorFactory = new UnnestOperator.UnnestOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(0), ImmutableList.of(BIGINT), ImmutableList.of(1), ImmutableList.of(arrayOfRowType), false);
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, BIGINT, DOUBLE, VARCHAR).row(1L, 2L, 4.2, "abc").row(1L, 3L, 6.6, "def").row(2L, 99L, 3.14, "pi").row(2L, null, null, null).row(6L, null, null, null).row(6L, 8L, 1.111, "tt").build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Aggregations