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);
}
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))));
}
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);
}
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();
}
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();
}
Aggregations