Package com.facebook.presto.type

Examples of com.facebook.presto.type.TypeRegistry


    @BeforeMethod(alwaysRun = true)
    public void setup()
            throws Exception
    {
        MetadataManager metadata = new MetadataManager(new FeaturesConfig().setExperimentalSyntaxEnabled(true), new TypeRegistry(), new SystemTablesMetadata());
        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


{
    @Test
    public void testRoundTrip()
    {
        ObjectMapperProvider objectMapperProvider = new ObjectMapperProvider();
        objectMapperProvider.setJsonDeserializers(ImmutableMap.<Class<?>, JsonDeserializer<?>>of(Type.class, new TypeDeserializer(new TypeRegistry())));
        JsonCodec<Signature> codec = new JsonCodecFactory(objectMapperProvider, true).jsonCodec(Signature.class);

        Signature expected = new Signature("function", StandardTypes.BIGINT, ImmutableList.of(StandardTypes.BOOLEAN, StandardTypes.DOUBLE, StandardTypes.VARCHAR));

        String json = codec.toJson(expected);
View Full Code Here

    @Test
    public void testBasic()
            throws Exception
    {
        TypeManager typeManager = new TypeRegistry();
        Signature signature = new Signature("foo", ImmutableList.of(typeParameter("T")), "T", ImmutableList.of("T"), false, true);
        assertNotNull(signature.bindTypeParameters(ImmutableList.<Type>of(BIGINT), true, typeManager));
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(VARCHAR), true, typeManager));
        assertNull(signature.bindTypeParameters(ImmutableList.of(VARCHAR, BIGINT), true, typeManager));
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(typeManager.getType("array<bigint>")), true, typeManager));
    }
View Full Code Here

    @Test
    public void testNonParametric()
            throws Exception
    {
        TypeManager typeManager = new TypeRegistry();
        Signature signature = new Signature("foo", ImmutableList.<TypeParameter>of(), "boolean", ImmutableList.of("bigint"), false, true);
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(BIGINT), true, typeManager));
        assertNull(signature.bindTypeParameters(ImmutableList.of(VARCHAR), true, typeManager));
        assertNull(signature.bindTypeParameters(ImmutableList.of(VARCHAR, BIGINT), true, typeManager));
        assertNull(signature.bindTypeParameters(ImmutableList.of(typeManager.getType("array<bigint>")), true, typeManager));
    }
View Full Code Here

    @Test
    public void testArray()
            throws Exception
    {
        TypeManager typeManager = new TypeRegistry();
        Signature signature = new Signature("get", ImmutableList.of(typeParameter("T")), "T", ImmutableList.of("array<T>"), false, true);
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(typeManager.getType("array<bigint>")), true, typeManager));
        assertNull(signature.bindTypeParameters(ImmutableList.of(BIGINT), true, typeManager));

        signature = new Signature("contains", ImmutableList.of(comparableTypeParameter("T")), "T", ImmutableList.of("array<T>", "T"), false, true);
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(typeManager.getType("array<bigint>"), BIGINT), true, typeManager));
        assertNull(signature.bindTypeParameters(ImmutableList.of(typeManager.getType("array<bigint>"), VARCHAR), true, typeManager));
        assertNull(signature.bindTypeParameters(ImmutableList.of(typeManager.getType("array<HyperLogLog>"), HYPER_LOG_LOG), true, typeManager));

        signature = new Signature("foo", ImmutableList.of(typeParameter("T")), "T", ImmutableList.of("array<T>", "array<T>"), false, true);
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(typeManager.getType("array<bigint>"), typeManager.getType("array<bigint>")), true, typeManager));
        assertNull(signature.bindTypeParameters(ImmutableList.of(typeManager.getType("array<bigint>"), typeManager.getType("array<varchar>")), true, typeManager));
    }
View Full Code Here

    @Test
    public void testMap()
            throws Exception
    {
        TypeManager typeManager = new TypeRegistry();
        Signature signature = new Signature("get", ImmutableList.of(typeParameter("K"), typeParameter("V")), "V", ImmutableList.of("map<K,V>", "K"), false, true);
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(typeManager.getType("map<bigint,varchar>"), BIGINT), true, typeManager));
        assertNull(signature.bindTypeParameters(ImmutableList.of(typeManager.getType("map<bigint,varchar>"), VARCHAR), true, typeManager));
    }
View Full Code Here

    @Test
    public void testVarArgs()
            throws Exception
    {
        TypeManager typeManager = new TypeRegistry();
        Signature signature = new Signature("foo", ImmutableList.of(typeParameter("T")), "boolean", ImmutableList.of("T"), true, true);
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(BIGINT), true, typeManager));
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(VARCHAR), true, typeManager));
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(BIGINT, BIGINT), true, typeManager));
        assertNull(signature.bindTypeParameters(ImmutableList.of(VARCHAR, BIGINT), true, typeManager));
View Full Code Here

    @Test
    public void testCoercion()
            throws Exception
    {
        TypeManager typeManager = new TypeRegistry();
        Signature signature = new Signature("foo", ImmutableList.of(typeParameter("T")), "boolean", ImmutableList.of("T", "double"), true, true);
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(DOUBLE, DOUBLE), true, typeManager));
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(BIGINT, BIGINT), true, typeManager));
        assertNotNull(signature.bindTypeParameters(ImmutableList.of(VARCHAR, BIGINT), true, typeManager));
        assertNull(signature.bindTypeParameters(ImmutableList.of(BIGINT, VARCHAR), true, typeManager));
View Full Code Here

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

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.