private ConcatFunction(TypeSignature type, String description) { super(new Signature( "concat", FunctionKind.SCALAR, ImmutableList.of(), ImmutableList.of(), type, ImmutableList.of(type), true)); this.description = description; }
protected SqlOperator(OperatorType operatorType, List<TypeVariableConstraint> typeVariableConstraints, List<LongVariableConstraint> longVariableConstraints, TypeSignature returnType, List<TypeSignature> argumentTypes) { // TODO This should take Signature! super(new Signature( mangleOperatorName(operatorType), FunctionKind.SCALAR, typeVariableConstraints, longVariableConstraints, returnType, argumentTypes, false)); }
protected AbstractGreatestLeast(String name, OperatorType operatorType) { super(new Signature( name, FunctionKind.SCALAR, ImmutableList.of(orderableTypeParameter("E")), ImmutableList.of(), parseTypeSignature("E"), ImmutableList.of(parseTypeSignature("E")), true)); this.operatorType = requireNonNull(operatorType, "operatorType is null"); }
public TryCastFunction() { super(new Signature( "TRY_CAST", FunctionKind.SCALAR, ImmutableList.of(typeVariable("F"), typeVariable("T")), ImmutableList.of(), parseTypeSignature("T"), ImmutableList.of(parseTypeSignature("F")), false)); }
public ArrayToElementConcatFunction() { super(new Signature(FUNCTION_NAME, FunctionKind.SCALAR, ImmutableList.of(typeVariable("E")), ImmutableList.of(), parseTypeSignature("array(E)"), ImmutableList.of(parseTypeSignature("array(E)"), parseTypeSignature("E")), false)); }
private MapFilterFunction() { super(new Signature( "map_filter", FunctionKind.SCALAR, ImmutableList.of(typeVariable("K"), typeVariable("V")), ImmutableList.of(), parseTypeSignature("map(K,V)"), ImmutableList.of(parseTypeSignature("map(K,V)"), parseTypeSignature("function(K,V,boolean)")), false)); }
public ArrayJoinWithNullReplacement() { super(new Signature(FUNCTION_NAME, FunctionKind.SCALAR, ImmutableList.of(typeVariable("T")), ImmutableList.of(), parseTypeSignature(StandardTypes.VARCHAR), ImmutableList.of(parseTypeSignature("array(T)"), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.VARCHAR)), false)); }
private TestVarArgsSum() { super(new Signature( "var_args_sum", FunctionKind.SCALAR, ImmutableList.of(), ImmutableList.of(), INTEGER.getTypeSignature(), ImmutableList.of(INTEGER.getTypeSignature()), true)); }
public static Signature getMagicLiteralFunctionSignature(Type type) { TypeSignature argumentType = typeForMagicLiteral(type).getTypeSignature(); return new Signature(MAGIC_LITERAL_FUNCTION_PREFIX + type.getTypeSignature(), SCALAR, type.getTypeSignature(), argumentType); }
@Override protected List<? extends OperatorFactory> createOperatorFactories() { OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice"); InternalAggregationFunction doubleSum = MetadataManager.createTestMetadataManager().getFunctionRegistry().getAggregateFunctionImplementation( new Signature("sum", AGGREGATE, DOUBLE.getTypeSignature(), DOUBLE.getTypeSignature())); AggregationOperatorFactory aggregationOperator = new AggregationOperatorFactory(1, new PlanNodeId("test"), Step.SINGLE, ImmutableList.of(doubleSum.bind(ImmutableList.of(0), Optional.empty())), false); return ImmutableList.of(tableScanOperator, aggregationOperator); }
@Test public void testMinLongArraySlice() { InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("min_by", AGGREGATE, parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature("array(bigint)"))); assertAggregation( function, "c", createStringsBlock("a", "b", "c"), createArrayBigintBlock(asList(asList(3L, 4L), null, asList(2L, 2L)))); }
@Test public void testNullPartial() { InternalAggregationFunction bigIntAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("array_agg", AGGREGATE, parseTypeSignature("array(bigint)"), parseTypeSignature(StandardTypes.BIGINT))); assertAggregation( bigIntAgg, Arrays.asList(null, 2L, null, 3L, null), createLongsBlock(new Long[] {null, 2L, null, 3L, null})); }
@Test public void testBigInt() { InternalAggregationFunction bigIntAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("array_agg", AGGREGATE, parseTypeSignature("array(bigint)"), parseTypeSignature(StandardTypes.BIGINT))); assertAggregation( bigIntAgg, Arrays.asList(2L, 1L, 2L), createLongsBlock(new Long[] {2L, 1L, 2L})); }
@Test public void testMinBooleanLongArray() { InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature("array(bigint)"), parseTypeSignature("array(bigint)"), parseTypeSignature(StandardTypes.BOOLEAN))); assertAggregation( function, null, createArrayBigintBlock(asList(asList(3L, 4L), null, null)), createBooleansBlock(true, false, true)); }
@Test public void testString() { InternalAggregationFunction stringAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("checksum", AGGREGATE, parseTypeSignature(VARBINARY), parseTypeSignature(VARCHAR))); Block block = createStringsBlock("a", "a", null, "b", "c"); assertAggregation(stringAgg, expectedChecksum(VarcharType.VARCHAR, block), block); }
@Override public InternalAggregationFunction getAggregationFunction() { return metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("approx_distinct", AGGREGATE, BIGINT.getTypeSignature(), INTEGER.getTypeSignature(), DOUBLE.getTypeSignature())); }
@Override public InternalAggregationFunction getAggregationFunction() { return metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("approx_distinct", AGGREGATE, BIGINT.getTypeSignature(), TINYINT.getTypeSignature(), DOUBLE.getTypeSignature())); }
@Test public void testMaxIntegerVarchar() { InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.INTEGER))); assertAggregation( function, "c", createStringsBlock("a", "b", "c"), createIntsBlock(1, 2, 3)); }
@Test public void testMinLongVarchar() { InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.BIGINT))); assertAggregation( function, "a", createStringsBlock("a", "b", "c"), createLongsBlock(1, 2, 3)); }
@Test public void testMinShortDecimalDecimal() { InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature("decimal(10,1)"), parseTypeSignature("decimal(10,1)"), parseTypeSignature("decimal(10,1)"))); assertAggregation( function, SqlDecimal.of("2.2"), createShortDecimalsBlock("1.1", "2.2", "3.3"), createShortDecimalsBlock("1.2", "1.0", "2.0")); }