Skip to content

Commit

Permalink
Remove usages of parseTypeSignature from functions
Browse files Browse the repository at this point in the history
  • Loading branch information
martint committed Oct 14, 2019
1 parent 937b18a commit c9a5427
Show file tree
Hide file tree
Showing 31 changed files with 131 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.functionTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.USE_BOXED_TYPE;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.functionType;
import static io.prestosql.util.Reflection.methodHandle;

/**
Expand All @@ -52,7 +52,9 @@ private ApplyFunction()
ImmutableList.of(typeVariable("T"), typeVariable("U")),
ImmutableList.of(),
new TypeSignature("U"),
ImmutableList.of(new TypeSignature("T"), parseTypeSignature("function(T,U)")),
ImmutableList.of(
new TypeSignature("T"),
functionType(new TypeSignature("T"), new TypeSignature("U"))),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.prestosql.spi.block.Block;
import io.prestosql.spi.block.BlockBuilder;
import io.prestosql.spi.type.Type;
import io.prestosql.spi.type.TypeSignature;
import io.prestosql.sql.gen.VarArgsToArrayAdapterGenerator;

import java.lang.invoke.MethodHandle;
Expand All @@ -34,7 +35,7 @@
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.RETURN_NULL_ON_NULL;
import static io.prestosql.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.sql.gen.VarArgsToArrayAdapterGenerator.generateVarArgsToArrayAdapter;
import static io.prestosql.util.Reflection.methodHandle;
import static java.util.Collections.nCopies;
Expand All @@ -56,8 +57,8 @@ private ArrayConcatFunction()
FunctionKind.SCALAR,
ImmutableList.of(typeVariable("E")),
ImmutableList.of(),
parseTypeSignature("array(E)"),
ImmutableList.of(parseTypeSignature("array(E)")),
arrayType(new TypeSignature("E")),
ImmutableList.of(arrayType(new TypeSignature("E"))),
true));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.USE_BOXED_TYPE;
import static io.prestosql.spi.StandardErrorCode.NOT_SUPPORTED;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.sql.gen.SqlTypeBytecodeExpression.constantType;
import static io.prestosql.util.CompilerUtils.defineClass;
import static io.prestosql.util.CompilerUtils.makeClassName;
Expand All @@ -77,7 +77,7 @@ public ArrayConstructor()
FunctionKind.SCALAR,
ImmutableList.of(typeVariable("E")),
ImmutableList.of(),
parseTypeSignature("array(E)"),
arrayType(new TypeSignature("E")),
ImmutableList.of(new TypeSignature("E"), new TypeSignature("E")),
true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
import io.prestosql.spi.block.BlockBuilder;
import io.prestosql.spi.type.StandardTypes;
import io.prestosql.spi.type.Type;
import io.prestosql.spi.type.TypeSignature;
import io.prestosql.spi.type.TypeSignatureParameter;

import java.lang.invoke.MethodHandle;

import static io.prestosql.metadata.Signature.typeVariable;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.RETURN_NULL_ON_NULL;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.util.Reflection.methodHandle;
import static java.lang.Math.toIntExact;

Expand All @@ -47,8 +48,8 @@ private ArrayFlattenFunction()
FunctionKind.SCALAR,
ImmutableList.of(typeVariable("E")),
ImmutableList.of(),
parseTypeSignature("array(E)"),
ImmutableList.of(parseTypeSignature("array(array(E))")),
arrayType(new TypeSignature("E")),
ImmutableList.of(arrayType(arrayType(new TypeSignature("E")))),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import static io.prestosql.spi.StandardErrorCode.GENERIC_INTERNAL_ERROR;
import static io.prestosql.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT;
import static io.prestosql.spi.function.OperatorType.CAST;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.spi.type.VarcharType.VARCHAR;
import static io.prestosql.util.Reflection.methodHandle;
import static java.lang.String.format;
Expand Down Expand Up @@ -97,7 +97,7 @@ public ArrayJoinWithNullReplacement()
ImmutableList.of(typeVariable("T")),
ImmutableList.of(),
VARCHAR.getTypeSignature(),
ImmutableList.of(parseTypeSignature("array(T)"), VARCHAR.getTypeSignature(), VARCHAR.getTypeSignature()),
ImmutableList.of(arrayType(new TypeSignature("T")), VARCHAR.getTypeSignature(), VARCHAR.getTypeSignature()),
false));
}

Expand Down Expand Up @@ -133,7 +133,7 @@ public ArrayJoin()
ImmutableList.of(typeVariable("T")),
ImmutableList.of(),
VARCHAR.getTypeSignature(),
ImmutableList.of(parseTypeSignature("array(T)"), VARCHAR.getTypeSignature()),
ImmutableList.of(arrayType(new TypeSignature("T")), VARCHAR.getTypeSignature()),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.RETURN_NULL_ON_NULL;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.USE_BOXED_TYPE;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.spi.type.TypeSignature.functionType;
import static io.prestosql.spi.type.TypeUtils.readNativeValue;
import static io.prestosql.util.Reflection.methodHandle;

Expand All @@ -52,7 +53,11 @@ private ArrayReduceFunction()
ImmutableList.of(typeVariable("T"), typeVariable("S"), typeVariable("R")),
ImmutableList.of(),
new TypeSignature("R"),
ImmutableList.of(parseTypeSignature("array(T)"), new TypeSignature("S"), parseTypeSignature("function(S,T,S)"), parseTypeSignature("function(S,R)")),
ImmutableList.of(
arrayType(new TypeSignature("T")),
new TypeSignature("S"),
functionType(new TypeSignature("S"), new TypeSignature("T"), new TypeSignature("S")),
functionType(new TypeSignature("S"), new TypeSignature("R"))),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import static io.prestosql.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT;
import static io.prestosql.spi.function.OperatorType.SUBSCRIPT;
import static io.prestosql.spi.type.BigintType.BIGINT;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.util.Reflection.methodHandle;
import static java.lang.Math.toIntExact;
import static java.lang.String.format;
Expand All @@ -56,7 +56,7 @@ protected ArraySubscriptOperator()
ImmutableList.of(typeVariable("E")),
ImmutableList.of(),
new TypeSignature("E"),
ImmutableList.of(parseTypeSignature("array(E)"), BIGINT.getTypeSignature()));
ImmutableList.of(arrayType(new TypeSignature("E")), BIGINT.getTypeSignature()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.prestosql.spi.block.Block;
import io.prestosql.spi.connector.ConnectorSession;
import io.prestosql.spi.type.Type;
import io.prestosql.spi.type.TypeSignature;
import io.prestosql.sql.gen.ArrayGeneratorUtils;
import io.prestosql.sql.gen.ArrayMapBytecodeExpression;
import io.prestosql.sql.gen.CachedInstanceBinder;
Expand All @@ -48,7 +49,7 @@
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.RETURN_NULL_ON_NULL;
import static io.prestosql.spi.function.OperatorType.CAST;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.util.CompilerUtils.defineClass;
import static io.prestosql.util.CompilerUtils.makeClassName;
import static io.prestosql.util.Reflection.methodHandle;
Expand All @@ -63,8 +64,8 @@ private ArrayToArrayCast()
super(CAST,
ImmutableList.of(typeVariable("F"), typeVariable("T")),
ImmutableList.of(),
parseTypeSignature("array(T)"),
ImmutableList.of(parseTypeSignature("array(F)")));
arrayType(new TypeSignature("T")),
ImmutableList.of(arrayType(new TypeSignature("F"))));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import static io.prestosql.metadata.Signature.typeVariable;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.RETURN_NULL_ON_NULL;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.util.Reflection.methodHandle;

public class ArrayToElementConcatFunction
Expand All @@ -50,8 +50,8 @@ public ArrayToElementConcatFunction()
FunctionKind.SCALAR,
ImmutableList.of(typeVariable("E")),
ImmutableList.of(),
parseTypeSignature("array(E)"),
ImmutableList.of(parseTypeSignature("array(E)"), new TypeSignature("E")),
arrayType(new TypeSignature("E")),
ImmutableList.of(arrayType(new TypeSignature("E")), new TypeSignature("E")),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.prestosql.spi.function.OperatorType;
import io.prestosql.spi.type.StandardTypes;
import io.prestosql.spi.type.Type;
import io.prestosql.spi.type.TypeSignature;
import io.prestosql.spi.type.TypeSignatureParameter;
import io.prestosql.util.JsonUtil.JsonGeneratorWriter;

Expand All @@ -39,7 +40,7 @@
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.RETURN_NULL_ON_NULL;
import static io.prestosql.spi.StandardErrorCode.INVALID_CAST_ARGUMENT;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.type.JsonType.JSON;
import static io.prestosql.util.Failures.checkCondition;
import static io.prestosql.util.JsonUtil.canCastToJson;
Expand All @@ -58,7 +59,7 @@ private ArrayToJsonCast()
ImmutableList.of(typeVariable("T")),
ImmutableList.of(),
JSON.getTypeSignature(),
ImmutableList.of(parseTypeSignature("array(T)")));
ImmutableList.of(arrayType(new TypeSignature("T"))));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.prestosql.spi.block.BlockBuilder;
import io.prestosql.spi.type.ArrayType;
import io.prestosql.spi.type.Type;
import io.prestosql.spi.type.TypeSignature;
import io.prestosql.sql.gen.CallSiteBinder;
import io.prestosql.sql.gen.lambda.UnaryFunctionInterface;

Expand All @@ -58,7 +59,8 @@
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.functionTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.RETURN_NULL_ON_NULL;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.spi.type.TypeSignature.functionType;
import static io.prestosql.sql.gen.SqlTypeBytecodeExpression.constantType;
import static io.prestosql.type.UnknownType.UNKNOWN;
import static io.prestosql.util.CompilerUtils.defineClass;
Expand All @@ -77,8 +79,10 @@ private ArrayTransformFunction()
FunctionKind.SCALAR,
ImmutableList.of(typeVariable("T"), typeVariable("U")),
ImmutableList.of(),
parseTypeSignature("array(U)"),
ImmutableList.of(parseTypeSignature("array(T)"), parseTypeSignature("function(T,U)")),
arrayType(new TypeSignature("U")),
ImmutableList.of(
arrayType(new TypeSignature("T")),
functionType(new TypeSignature("T"), new TypeSignature("U"))),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.RETURN_NULL_ON_NULL;
import static io.prestosql.spi.function.OperatorType.CAST;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.type.UnknownType.UNKNOWN;
import static io.prestosql.util.Reflection.methodHandle;

public final class CastFromUnknownOperator
Expand All @@ -42,7 +42,7 @@ public CastFromUnknownOperator()
ImmutableList.of(typeVariable("E")),
ImmutableList.of(),
new TypeSignature("E"),
ImmutableList.of(parseTypeSignature("unknown")));
ImmutableList.of(UNKNOWN.getTypeSignature()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import static io.prestosql.metadata.Signature.typeVariable;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.RETURN_NULL_ON_NULL;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.util.Reflection.methodHandle;

public class ElementToArrayConcatFunction
Expand All @@ -51,8 +51,8 @@ public ElementToArrayConcatFunction()
FunctionKind.SCALAR,
ImmutableList.of(typeVariable("E")),
ImmutableList.of(),
parseTypeSignature("array(E)"),
ImmutableList.of(new TypeSignature("E"), parseTypeSignature("array(E)")),
arrayType(new TypeSignature("E")),
ImmutableList.of(new TypeSignature("E"), arrayType(new TypeSignature("E"))),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import static com.google.common.primitives.Primitives.wrap;
import static io.prestosql.metadata.Signature.typeVariable;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.functionTypeArgumentProperty;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.functionType;
import static io.prestosql.util.Reflection.methodHandle;

/**
Expand All @@ -50,7 +50,7 @@ private InvokeFunction()
ImmutableList.of(typeVariable("T")),
ImmutableList.of(),
new TypeSignature("T"),
ImmutableList.of(parseTypeSignature("function(T)")),
ImmutableList.of(functionType(new TypeSignature("T"))),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
import io.prestosql.metadata.Metadata;
import io.prestosql.metadata.Signature;
import io.prestosql.metadata.SqlScalarFunction;
import io.prestosql.spi.type.TypeSignature;

import static io.prestosql.metadata.FunctionKind.SCALAR;
import static io.prestosql.metadata.Signature.typeVariable;
import static io.prestosql.operator.scalar.JsonToArrayCast.JSON_TO_ARRAY;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.spi.type.VarcharType.VARCHAR;

public final class JsonStringToArrayCast
Expand All @@ -38,7 +39,7 @@ private JsonStringToArrayCast()
SCALAR,
ImmutableList.of(typeVariable("T")),
ImmutableList.of(),
parseTypeSignature("array(T)"),
arrayType(new TypeSignature("T")),
ImmutableList.of(VARCHAR.getTypeSignature()),
false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
import io.prestosql.metadata.Metadata;
import io.prestosql.metadata.Signature;
import io.prestosql.metadata.SqlScalarFunction;
import io.prestosql.spi.type.TypeSignature;

import static io.prestosql.metadata.FunctionKind.SCALAR;
import static io.prestosql.metadata.Signature.comparableTypeParameter;
import static io.prestosql.metadata.Signature.typeVariable;
import static io.prestosql.operator.scalar.JsonToMapCast.JSON_TO_MAP;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.mapType;
import static io.prestosql.spi.type.VarcharType.VARCHAR;

public final class JsonStringToMapCast
Expand All @@ -39,7 +40,7 @@ private JsonStringToMapCast()
SCALAR,
ImmutableList.of(comparableTypeParameter("K"), typeVariable("V")),
ImmutableList.of(),
parseTypeSignature("map(K,V)"),
mapType(new TypeSignature("K"), new TypeSignature("V")),
ImmutableList.of(VARCHAR.getTypeSignature()),
false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.prestosql.spi.type.ArrayType;
import io.prestosql.spi.type.StandardTypes;
import io.prestosql.spi.type.Type;
import io.prestosql.spi.type.TypeSignature;
import io.prestosql.spi.type.TypeSignatureParameter;
import io.prestosql.util.JsonCastException;
import io.prestosql.util.JsonUtil.BlockBuilderAppender;
Expand All @@ -41,7 +42,7 @@
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.ArgumentProperty.valueTypeArgumentProperty;
import static io.prestosql.operator.scalar.ScalarFunctionImplementation.NullConvention.RETURN_NULL_ON_NULL;
import static io.prestosql.spi.StandardErrorCode.INVALID_CAST_ARGUMENT;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.type.JsonType.JSON;
import static io.prestosql.util.Failures.checkCondition;
import static io.prestosql.util.JsonUtil.JSON_FACTORY;
Expand All @@ -62,7 +63,7 @@ private JsonToArrayCast()
super(OperatorType.CAST,
ImmutableList.of(typeVariable("T")),
ImmutableList.of(),
parseTypeSignature("array(T)"),
arrayType(new TypeSignature("T")),
ImmutableList.of(JSON.getTypeSignature()));
}

Expand Down
Loading

0 comments on commit c9a5427

Please sign in to comment.