Search in sources :

Example 21 with MetadataManager

use of com.facebook.presto.metadata.MetadataManager in project presto by prestodb.

the class TestUnnestOperator method testUnnest.

@Test
public void testUnnest() {
    MetadataManager 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), false);
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, BIGINT, BIGINT, BIGINT).row(1L, 2L, 4L, 5L).row(1L, 3L, null, null).row(2L, 99L, null, null).row(6L, 7L, 9L, 10L).row(6L, 8L, 11L, 12L).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) ArrayType(com.facebook.presto.common.type.ArrayType) Type(com.facebook.presto.common.type.Type) BlockAssertions.createMapType(com.facebook.presto.block.BlockAssertions.createMapType) RowType(com.facebook.presto.common.type.RowType) DecimalType.createDecimalType(com.facebook.presto.common.type.DecimalType.createDecimalType) MetadataManager(com.facebook.presto.metadata.MetadataManager) MetadataManager.createTestMetadataManager(com.facebook.presto.metadata.MetadataManager.createTestMetadataManager) OperatorFactory(com.facebook.presto.operator.OperatorFactory) Page(com.facebook.presto.common.Page) TestUnnesterUtil.buildExpectedPage(com.facebook.presto.operator.unnest.TestUnnesterUtil.buildExpectedPage) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 22 with MetadataManager

use of com.facebook.presto.metadata.MetadataManager in project presto by prestodb.

the class TestTransactionManager method registerConnector.

private static void registerConnector(CatalogManager catalogManager, TransactionManager transactionManager, String catalogName, ConnectorId connectorId, Connector connector) {
    ConnectorId systemId = createSystemTablesConnectorId(connectorId);
    InternalNodeManager nodeManager = new InMemoryNodeManager();
    MetadataManager metadata = MetadataManager.createTestMetadataManager(catalogManager);
    catalogManager.registerCatalog(new Catalog(catalogName, connectorId, connector, createInformationSchemaConnectorId(connectorId), new InformationSchemaConnector(catalogName, nodeManager, metadata, new AllowAllAccessControl(), ImmutableList.of()), systemId, new SystemConnector(systemId, nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, connectorId))));
}
Also used : SystemConnector(com.facebook.presto.connector.system.SystemConnector) InformationSchemaConnector(com.facebook.presto.connector.informationSchema.InformationSchemaConnector) InternalNodeManager(com.facebook.presto.metadata.InternalNodeManager) MetadataManager(com.facebook.presto.metadata.MetadataManager) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) Catalog(com.facebook.presto.metadata.Catalog) ConnectorId.createSystemTablesConnectorId(com.facebook.presto.spi.ConnectorId.createSystemTablesConnectorId) ConnectorId.createInformationSchemaConnectorId(com.facebook.presto.spi.ConnectorId.createInformationSchemaConnectorId) ConnectorId(com.facebook.presto.spi.ConnectorId) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager)

Example 23 with MetadataManager

use of com.facebook.presto.metadata.MetadataManager in project presto by prestodb.

the class TestScalarStatsCalculator method testVarbinaryConstant.

@Test
public void testVarbinaryConstant() {
    MetadataManager metadata = createTestMetadataManager();
    LiteralEncoder literalEncoder = new LiteralEncoder(metadata.getBlockEncodingSerde());
    Expression expression = literalEncoder.toExpression(Slices.utf8Slice("ala ma kota"), VARBINARY);
    assertCalculate(expression).distinctValuesCount(1.0).lowValueUnknown().highValueUnknown().nullsFraction(0.0);
}
Also used : MetadataManager(com.facebook.presto.metadata.MetadataManager) MetadataManager.createTestMetadataManager(com.facebook.presto.metadata.MetadataManager.createTestMetadataManager) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) RowExpression(com.facebook.presto.spi.relation.RowExpression) Expression(com.facebook.presto.sql.tree.Expression) LiteralEncoder(com.facebook.presto.sql.planner.LiteralEncoder) Test(org.testng.annotations.Test)

Example 24 with MetadataManager

use of com.facebook.presto.metadata.MetadataManager in project presto by prestodb.

the class CommonSubExpressionBenchmark method setup.

@Setup
public void setup() {
    Type type = TYPE_MAP.get(this.functionType);
    VariableReferenceExpression variable = new VariableReferenceExpression(Optional.empty(), type.getDisplayName().toLowerCase(ENGLISH) + "0", type);
    symbolTypes = ImmutableMap.of(variable.getName(), type);
    sourceLayout = ImmutableMap.of(variable, 0);
    inputPage = createPage(functionType, dictionaryBlocks);
    List<RowExpression> projections = getProjections(this.functionType);
    projectionTypes = projections.stream().map(RowExpression::getType).collect(toList());
    MetadataManager metadata = createTestMetadataManager();
    PageFunctionCompiler pageFunctionCompiler = new PageFunctionCompiler(metadata, 0);
    ExpressionCompiler expressionCompiler = new ExpressionCompiler(metadata, pageFunctionCompiler);
    pageProcessor = expressionCompiler.compilePageProcessor(TEST_SESSION.getSqlFunctionProperties(), Optional.of(getFilter(functionType)), projections, optimizeCommonSubExpression, Optional.empty()).get();
    cursorProcessor = expressionCompiler.compileCursorProcessor(TEST_SESSION.getSqlFunctionProperties(), Optional.of(getFilter(functionType)), projections, "key", optimizeCommonSubExpression).get();
}
Also used : Type(com.facebook.presto.common.type.Type) MetadataManager(com.facebook.presto.metadata.MetadataManager) MetadataManager.createTestMetadataManager(com.facebook.presto.metadata.MetadataManager.createTestMetadataManager) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) RowExpression(com.facebook.presto.spi.relation.RowExpression) Setup(org.openjdk.jmh.annotations.Setup)

Example 25 with MetadataManager

use of com.facebook.presto.metadata.MetadataManager in project presto by prestodb.

the class PageProcessorBenchmark method setup.

@Setup
public void setup() {
    Type type = TYPE_MAP.get(this.type);
    for (int i = 0; i < columnCount; i++) {
        VariableReferenceExpression variable = new VariableReferenceExpression(Optional.empty(), type.getDisplayName().toLowerCase(ENGLISH) + i, type);
        symbolTypes.put(variable.getName(), type);
        sourceLayout.put(variable, i);
    }
    List<RowExpression> projections = getProjections(type);
    types = projections.stream().map(RowExpression::getType).collect(toList());
    MetadataManager metadata = createTestMetadataManager();
    PageFunctionCompiler pageFunctionCompiler = new PageFunctionCompiler(metadata, 0);
    inputPage = createPage(types, dictionaryBlocks);
    pageProcessor = new ExpressionCompiler(metadata, pageFunctionCompiler).compilePageProcessor(TEST_SESSION.getSqlFunctionProperties(), Optional.of(getFilter(type)), projections).get();
    recordSet = new PageRecordSet(types, inputPage);
    cursorProcessor = new ExpressionCompiler(metadata, pageFunctionCompiler).compileCursorProcessor(TEST_SESSION.getSqlFunctionProperties(), Optional.of(getFilter(type)), projections, "key").get();
}
Also used : Type(com.facebook.presto.common.type.Type) MetadataManager(com.facebook.presto.metadata.MetadataManager) MetadataManager.createTestMetadataManager(com.facebook.presto.metadata.MetadataManager.createTestMetadataManager) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) RowExpression(com.facebook.presto.spi.relation.RowExpression) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

MetadataManager (com.facebook.presto.metadata.MetadataManager)27 MetadataManager.createTestMetadataManager (com.facebook.presto.metadata.MetadataManager.createTestMetadataManager)15 Test (org.testng.annotations.Test)15 MaterializedResult (com.facebook.presto.testing.MaterializedResult)11 Page (com.facebook.presto.common.Page)8 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)8 Type (com.facebook.presto.common.type.Type)7 RowExpression (com.facebook.presto.spi.relation.RowExpression)7 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)7 BlockAssertions.createMapType (com.facebook.presto.block.BlockAssertions.createMapType)5 ArrayType (com.facebook.presto.common.type.ArrayType)5 DecimalType.createDecimalType (com.facebook.presto.common.type.DecimalType.createDecimalType)5 RowType (com.facebook.presto.common.type.RowType)5 OperatorFactory (com.facebook.presto.operator.OperatorFactory)5 TestUnnesterUtil.buildExpectedPage (com.facebook.presto.operator.unnest.TestUnnesterUtil.buildExpectedPage)5 ConnectorId (com.facebook.presto.spi.ConnectorId)5 PageFunctionCompiler (com.facebook.presto.sql.gen.PageFunctionCompiler)5 Page (com.facebook.presto.spi.Page)4 ExpressionCompiler (com.facebook.presto.sql.gen.ExpressionCompiler)4 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)4