Package com.facebook.presto.type

Examples of com.facebook.presto.type.TypeRegistry


public class TestFunctionRegistry
{
    @Test
    public void testIdentityCast()
    {
        FunctionRegistry registry = new FunctionRegistry(new TypeRegistry(), true);
        FunctionInfo exactOperator = registry.getCoercion(HYPER_LOG_LOG, HYPER_LOG_LOG);
        assertEquals(exactOperator.getSignature().getName(), mangleOperatorName(OperatorType.CAST.name()));
        assertEquals(exactOperator.getArgumentTypes(), ImmutableList.of(StandardTypes.HYPER_LOG_LOG));
        assertEquals(exactOperator.getReturnType(), StandardTypes.HYPER_LOG_LOG);
    }
View Full Code Here


    }

    @Test
    public void testExactMatchBeforeCoercion()
    {
        TypeRegistry typeManager = new TypeRegistry();
        FunctionRegistry registry = new FunctionRegistry(typeManager, true);
        boolean foundOperator = false;
        for (ParametricFunction function : registry.listOperators()) {
            OperatorType operatorType = unmangleOperator(function.getSignature().getName());
            if (operatorType == OperatorType.CAST) {
View Full Code Here

        Signature signature = getMagicLiteralFunctionSignature(TIMESTAMP_WITH_TIME_ZONE);
        assertEquals(signature.getName(), "$literal$timestamp with time zone");
        assertEquals(signature.getArgumentTypes(), ImmutableList.of(StandardTypes.BIGINT));
        assertEquals(signature.getReturnType(), StandardTypes.TIMESTAMP_WITH_TIME_ZONE);

        FunctionRegistry registry = new FunctionRegistry(new TypeRegistry(), true);
        FunctionInfo function = registry.resolveFunction(QualifiedName.of(signature.getName()), signature.getArgumentTypes(), false);
        assertEquals(function.getArgumentTypes(), ImmutableList.of(StandardTypes.BIGINT));
        assertEquals(signature.getReturnType(), StandardTypes.TIMESTAMP_WITH_TIME_ZONE);
    }
View Full Code Here

    }

    @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "\\QFunction already registered: custom_add(bigint,bigint):bigint\\E")
    public void testDuplicateFunctions()
    {
        List<ParametricFunction> functions = new FunctionListBuilder(new TypeRegistry())
                .scalar(CustomFunctions.class)
                .getFunctions();

        functions = FluentIterable.from(functions).filter(new Predicate<ParametricFunction>()
        {
            @Override
            public boolean apply(ParametricFunction input)
            {
                return input.getSignature().getName().equals("custom_add");
            }
        }).toList();

        FunctionRegistry registry = new FunctionRegistry(new TypeRegistry(), true);
        registry.addFunctions(functions);
        registry.addFunctions(functions);
    }
View Full Code Here

    @Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "'sum' is both an aggregation and a scalar function")
    public void testConflictingScalarAggregation()
            throws Exception
    {
        List<ParametricFunction> functions = new FunctionListBuilder(new TypeRegistry())
                .scalar(ScalarSum.class)
                .getFunctions();

        FunctionRegistry registry = new FunctionRegistry(new TypeRegistry(), true);
        registry.addFunctions(functions);
    }
View Full Code Here

    @Test
    public void testListingHiddenFunctions()
            throws Exception
    {
        FunctionRegistry registry = new FunctionRegistry(new TypeRegistry(), true);
        List<ParametricFunction> functions = registry.list();
        List<String> names = transform(functions, nameGetter());

        assertTrue(names.contains("length"), "Expected function names " + names + " to contain 'length'");
        assertTrue(names.contains("stddev"), "Expected function names " + names + " to contain 'stddev'");
View Full Code Here

    @BeforeMethod(alwaysRun = true)
    public void setup()
            throws Exception
    {
        MetadataManager metadata = new MetadataManager(new FeaturesConfig().setExperimentalSyntaxEnabled(true), new TypeRegistry());
        metadata.addConnectorMetadata("tpch", "tpch", new TestingMetadata());
        metadata.addConnectorMetadata("c2", "c2", new TestingMetadata());
        metadata.addConnectorMetadata("c3", "c3", new TestingMetadata());

        SchemaTableName table1 = new SchemaTableName("default", "t1");
View Full Code Here

            OutputPartitioning.NONE,
            ImmutableList.<Symbol>of());

    public static LocalExecutionPlanner createTestingPlanner()
    {
        MetadataManager metadata = new MetadataManager(new FeaturesConfig(), new TypeRegistry());

        DataStreamManager dataStreamProvider = new DataStreamManager();
        dataStreamProvider.addConnectorDataStreamProvider("test", new TestingDataStreamProvider());
        return new LocalExecutionPlanner(
                metadata,
View Full Code Here

    {
        inputPage = createInputPage();

        handCodedProcessor = new Tpch1FilterAndProject();

        MetadataManager metadata = new MetadataManager(new FeaturesConfig(), new TypeRegistry());
        compiledProcessor = new ExpressionCompiler(metadata).compilePageProcessor(FILTER, ImmutableList.of(PROJECT));
    }
View Full Code Here

    @BeforeMethod
    public void setupDatabase()
            throws Exception
    {
        TypeRegistry typeRegistry = new TypeRegistry();
        DBI dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime());
        dbi.registerMapper(new TableColumn.Mapper(typeRegistry));
        dbi.registerMapper(new RaptorPartitionKey.Mapper(typeRegistry));
        dummyHandle = dbi.open();
        metadata = new RaptorMetadata(new RaptorConnectorId("default"), dbi, new DatabaseShardManager(dbi));
View Full Code Here

TOP

Related Classes of com.facebook.presto.type.TypeRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.