Search in sources :

Example 26 with FeaturesConfig

use of com.facebook.presto.sql.analyzer.FeaturesConfig in project presto by prestodb.

the class TestFunctionRegistry method testMagicLiteralFunction.

@Test
public void testMagicLiteralFunction() {
    Signature signature = getMagicLiteralFunctionSignature(TIMESTAMP_WITH_TIME_ZONE);
    assertEquals(signature.getName(), "$literal$timestamp with time zone");
    assertEquals(signature.getArgumentTypes(), ImmutableList.of(parseTypeSignature(StandardTypes.BIGINT)));
    assertEquals(signature.getReturnType().getBase(), StandardTypes.TIMESTAMP_WITH_TIME_ZONE);
    TypeRegistry typeManager = new TypeRegistry();
    FunctionRegistry registry = new FunctionRegistry(typeManager, new BlockEncodingManager(typeManager), new FeaturesConfig());
    Signature function = registry.resolveFunction(QualifiedName.of(signature.getName()), fromTypeSignatures(signature.getArgumentTypes()));
    assertEquals(function.getArgumentTypes(), ImmutableList.of(parseTypeSignature(StandardTypes.BIGINT)));
    assertEquals(signature.getReturnType().getBase(), StandardTypes.TIMESTAMP_WITH_TIME_ZONE);
}
Also used : BlockEncodingManager(com.facebook.presto.block.BlockEncodingManager) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) TypeSignature(com.facebook.presto.spi.type.TypeSignature) FunctionRegistry.getMagicLiteralFunctionSignature(com.facebook.presto.metadata.FunctionRegistry.getMagicLiteralFunctionSignature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) TypeRegistry(com.facebook.presto.type.TypeRegistry) Test(org.testng.annotations.Test)

Example 27 with FeaturesConfig

use of com.facebook.presto.sql.analyzer.FeaturesConfig in project presto by prestodb.

the class TestCostCalculator method setUp.

@BeforeClass
public void setUp() {
    TaskCountEstimator taskCountEstimator = new TaskCountEstimator(() -> NUMBER_OF_NODES);
    costCalculatorUsingExchanges = new CostCalculatorUsingExchanges(taskCountEstimator);
    costCalculatorWithEstimatedExchanges = new CostCalculatorWithEstimatedExchanges(costCalculatorUsingExchanges, taskCountEstimator);
    session = testSessionBuilder().setCatalog("tpch").build();
    CatalogManager catalogManager = new CatalogManager();
    catalogManager.registerCatalog(createBogusTestingCatalog("tpch"));
    transactionManager = createTestTransactionManager(catalogManager);
    metadata = createTestMetadataManager(transactionManager, new FeaturesConfig());
    finalizerService = new FinalizerService();
    finalizerService.start();
    nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), new InMemoryNodeManager(), new NodeSelectionStats(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(finalizerService), new ThrowingNodeTtlFetcherManager(), new NoOpQueryManager(), new SimpleTtlNodeSelectorConfig());
    PartitioningProviderManager partitioningProviderManager = new PartitioningProviderManager();
    nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager, new NodeSelectionStats());
    planFragmenter = new PlanFragmenter(metadata, nodePartitioningManager, new QueryManagerConfig(), new SqlParser(), new FeaturesConfig());
}
Also used : NodeTaskMap(com.facebook.presto.execution.NodeTaskMap) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) SqlParser(com.facebook.presto.sql.parser.SqlParser) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) PlanFragmenter(com.facebook.presto.sql.planner.PlanFragmenter) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) CatalogManager(com.facebook.presto.metadata.CatalogManager) NodePartitioningManager(com.facebook.presto.sql.planner.NodePartitioningManager) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) FinalizerService(com.facebook.presto.util.FinalizerService) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) QueryManagerConfig(com.facebook.presto.execution.QueryManagerConfig) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) BeforeClass(org.testng.annotations.BeforeClass)

Example 28 with FeaturesConfig

use of com.facebook.presto.sql.analyzer.FeaturesConfig in project presto by prestodb.

the class TestSetRoleTask method setUp.

@BeforeClass
public void setUp() throws Exception {
    CatalogManager catalogManager = new CatalogManager();
    transactionManager = createTestTransactionManager(catalogManager);
    accessControl = new AllowAllAccessControl();
    metadata = MetadataManager.createTestMetadataManager(transactionManager, new FeaturesConfig());
    catalogManager.registerCatalog(createBogusTestingCatalog(CATALOG_NAME));
    executor = newCachedThreadPool(daemonThreadsNamed("test-set-role-task-executor-%s"));
    parser = new SqlParser();
}
Also used : AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) SqlParser(com.facebook.presto.sql.parser.SqlParser) CatalogManager(com.facebook.presto.metadata.CatalogManager) BeforeClass(org.testng.annotations.BeforeClass)

Example 29 with FeaturesConfig

use of com.facebook.presto.sql.analyzer.FeaturesConfig in project presto by prestodb.

the class TestHivePageSink method createPageSink.

private static ConnectorPageSink createPageSink(HiveTransactionHandle transaction, HiveClientConfig config, MetastoreClientConfig metastoreClientConfig, ExtendedHiveMetastore metastore, Path outputPath, HiveWriterStats stats) {
    LocationHandle locationHandle = new LocationHandle(outputPath, outputPath, Optional.empty(), NEW, DIRECT_TO_TARGET_NEW_DIRECTORY);
    HiveOutputTableHandle handle = new HiveOutputTableHandle(SCHEMA_NAME, TABLE_NAME, getColumnHandles(), new HivePageSinkMetadata(new SchemaTableName(SCHEMA_NAME, TABLE_NAME), metastore.getTable(METASTORE_CONTEXT, SCHEMA_NAME, TABLE_NAME), ImmutableMap.of()), locationHandle, config.getHiveStorageFormat(), config.getHiveStorageFormat(), config.getHiveStorageFormat(), config.getCompressionCodec(), ImmutableList.of(), Optional.empty(), ImmutableList.of(), "test", ImmutableMap.of(), Optional.empty());
    HdfsEnvironment hdfsEnvironment = createTestHdfsEnvironment(config, metastoreClientConfig);
    HivePageSinkProvider provider = new HivePageSinkProvider(getDefaultHiveFileWriterFactories(config, metastoreClientConfig), hdfsEnvironment, PAGE_SORTER, metastore, new GroupByHashPageIndexerFactory(new JoinCompiler(MetadataManager.createTestMetadataManager(), new FeaturesConfig())), FUNCTION_AND_TYPE_MANAGER, config, metastoreClientConfig, new HiveLocationService(hdfsEnvironment), HiveTestUtils.PARTITION_UPDATE_CODEC, HiveTestUtils.PARTITION_UPDATE_SMILE_CODEC, new TestingNodeManager("fake-environment"), new HiveEventClient(), new HiveSessionProperties(config, new OrcFileWriterConfig(), new ParquetFileWriterConfig(), new CacheConfig()), stats, getDefaultOrcFileWriterFactory(config, metastoreClientConfig), HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER);
    return provider.createPageSink(transaction, getSession(config), handle, TEST_HIVE_PAGE_SINK_CONTEXT);
}
Also used : JoinCompiler(com.facebook.presto.sql.gen.JoinCompiler) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) HivePageSinkMetadata(com.facebook.presto.hive.metastore.HivePageSinkMetadata) SchemaTableName(com.facebook.presto.spi.SchemaTableName) HiveTestUtils.createTestHdfsEnvironment(com.facebook.presto.hive.HiveTestUtils.createTestHdfsEnvironment) TestingNodeManager(com.facebook.presto.testing.TestingNodeManager) GroupByHashPageIndexerFactory(com.facebook.presto.GroupByHashPageIndexerFactory) CacheConfig(com.facebook.presto.cache.CacheConfig)

Example 30 with FeaturesConfig

use of com.facebook.presto.sql.analyzer.FeaturesConfig in project presto by prestodb.

the class TestHashSemiJoinOperator method testProbeSideNulls.

@Test(dataProvider = "hashEnabledValues")
public void testProbeSideNulls(boolean hashEnabled) {
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    // build
    OperatorContext operatorContext = driverContext.addOperatorContext(0, new PlanNodeId("test"), ValuesOperator.class.getSimpleName());
    List<Type> buildTypes = ImmutableList.of(BIGINT);
    RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), buildTypes);
    Operator buildOperator = new ValuesOperator(operatorContext, rowPagesBuilder.row(0L).row(1L).row(3L).build());
    SetBuilderOperatorFactory setBuilderOperatorFactory = new SetBuilderOperatorFactory(1, new PlanNodeId("test"), buildTypes.get(0), 0, rowPagesBuilder.getHashChannel(), 10, new JoinCompiler(createTestMetadataManager(), new FeaturesConfig()));
    Operator setBuilderOperator = setBuilderOperatorFactory.createOperator(driverContext);
    Driver driver = Driver.createDriver(driverContext, buildOperator, setBuilderOperator);
    while (!driver.isFinished()) {
        driver.process();
    }
    // probe
    List<Type> probeTypes = ImmutableList.of(BIGINT);
    RowPagesBuilder rowPagesBuilderProbe = rowPagesBuilder(hashEnabled, Ints.asList(0), probeTypes);
    List<Page> probeInput = rowPagesBuilderProbe.row(0L).row((Object) null).row(1L).row(2L).build();
    HashSemiJoinOperatorFactory joinOperatorFactory = new HashSemiJoinOperatorFactory(2, new PlanNodeId("test"), setBuilderOperatorFactory.getSetProvider(), rowPagesBuilderProbe.getTypes(), 0);
    // expected
    MaterializedResult expected = resultBuilder(driverContext.getSession(), concat(probeTypes, ImmutableList.of(BOOLEAN))).row(0L, true).row(null, null).row(1L, true).row(2L, false).build();
    OperatorAssertion.assertOperatorEquals(joinOperatorFactory, driverContext, probeInput, expected, hashEnabled, ImmutableList.of(probeTypes.size()));
}
Also used : JoinCompiler(com.facebook.presto.sql.gen.JoinCompiler) RowPagesBuilder(com.facebook.presto.RowPagesBuilder) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) SetBuilderOperatorFactory(com.facebook.presto.operator.SetBuilderOperator.SetBuilderOperatorFactory) Page(com.facebook.presto.common.Page) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) Type(com.facebook.presto.common.type.Type) MaterializedResult(com.facebook.presto.testing.MaterializedResult) HashSemiJoinOperatorFactory(com.facebook.presto.operator.HashSemiJoinOperator.HashSemiJoinOperatorFactory) Test(org.testng.annotations.Test)

Aggregations

FeaturesConfig (com.facebook.presto.sql.analyzer.FeaturesConfig)39 Test (org.testng.annotations.Test)20 JoinCompiler (com.facebook.presto.sql.gen.JoinCompiler)14 BlockEncodingManager (com.facebook.presto.block.BlockEncodingManager)10 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)9 TypeRegistry (com.facebook.presto.type.TypeRegistry)9 Page (com.facebook.presto.common.Page)7 Type (com.facebook.presto.common.type.Type)7 SetBuilderOperatorFactory (com.facebook.presto.operator.SetBuilderOperator.SetBuilderOperatorFactory)6 RowPagesBuilder (com.facebook.presto.RowPagesBuilder)5 TypeSignature.parseTypeSignature (com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)5 BlockEncodingManager (com.facebook.presto.common.block.BlockEncodingManager)4 CatalogManager (com.facebook.presto.metadata.CatalogManager)4 FunctionRegistry (com.facebook.presto.metadata.FunctionRegistry)4 FunctionRegistry.getMagicLiteralFunctionSignature (com.facebook.presto.metadata.FunctionRegistry.getMagicLiteralFunctionSignature)4 HashSemiJoinOperatorFactory (com.facebook.presto.operator.HashSemiJoinOperator.HashSemiJoinOperatorFactory)4 ImmutableList (com.google.common.collect.ImmutableList)4 List (java.util.List)4 BeforeClass (org.testng.annotations.BeforeClass)4 CounterStat (com.facebook.airlift.stats.CounterStat)3