Search in sources :

Example 1 with DOUBLE

use of com.facebook.presto.common.type.StandardTypes.DOUBLE in project presto by prestodb.

the class TestRowParametricType method testTypeSignatureRoundTrip.

@Test
public void testTypeSignatureRoundTrip() {
    FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
    TypeSignature typeSignature = new TypeSignature(ROW, TypeSignatureParameter.of(new NamedTypeSignature(Optional.of(new RowFieldName("col1", false)), new TypeSignature(BIGINT))), TypeSignatureParameter.of(new NamedTypeSignature(Optional.of(new RowFieldName("col2", true)), new TypeSignature(DOUBLE))));
    List<TypeParameter> parameters = typeSignature.getParameters().stream().map(parameter -> TypeParameter.of(parameter, functionAndTypeManager)).collect(Collectors.toList());
    Type rowType = RowParametricType.ROW.createType(parameters);
    assertEquals(rowType.getTypeSignature(), typeSignature);
}
Also used : FunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager) TypeSignatureParameter(com.facebook.presto.common.type.TypeSignatureParameter) Assert.assertEquals(com.facebook.presto.testing.assertions.Assert.assertEquals) Test(org.testng.annotations.Test) ROW(com.facebook.presto.common.type.StandardTypes.ROW) Collectors(java.util.stream.Collectors) FunctionAndTypeManager.createTestFunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager.createTestFunctionAndTypeManager) TypeSignature(com.facebook.presto.common.type.TypeSignature) DOUBLE(com.facebook.presto.common.type.StandardTypes.DOUBLE) List(java.util.List) Optional(java.util.Optional) RowFieldName(com.facebook.presto.common.type.RowFieldName) TypeParameter(com.facebook.presto.common.type.TypeParameter) BIGINT(com.facebook.presto.common.type.StandardTypes.BIGINT) Type(com.facebook.presto.common.type.Type) NamedTypeSignature(com.facebook.presto.common.type.NamedTypeSignature) TypeSignature(com.facebook.presto.common.type.TypeSignature) NamedTypeSignature(com.facebook.presto.common.type.NamedTypeSignature) TypeParameter(com.facebook.presto.common.type.TypeParameter) Type(com.facebook.presto.common.type.Type) FunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager) FunctionAndTypeManager.createTestFunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager.createTestFunctionAndTypeManager) RowFieldName(com.facebook.presto.common.type.RowFieldName) NamedTypeSignature(com.facebook.presto.common.type.NamedTypeSignature) Test(org.testng.annotations.Test)

Aggregations

NamedTypeSignature (com.facebook.presto.common.type.NamedTypeSignature)1 RowFieldName (com.facebook.presto.common.type.RowFieldName)1 BIGINT (com.facebook.presto.common.type.StandardTypes.BIGINT)1 DOUBLE (com.facebook.presto.common.type.StandardTypes.DOUBLE)1 ROW (com.facebook.presto.common.type.StandardTypes.ROW)1 Type (com.facebook.presto.common.type.Type)1 TypeParameter (com.facebook.presto.common.type.TypeParameter)1 TypeSignature (com.facebook.presto.common.type.TypeSignature)1 TypeSignatureParameter (com.facebook.presto.common.type.TypeSignatureParameter)1 FunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager)1 FunctionAndTypeManager.createTestFunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager.createTestFunctionAndTypeManager)1 Assert.assertEquals (com.facebook.presto.testing.assertions.Assert.assertEquals)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Test (org.testng.annotations.Test)1