public static Signature notSignature() { return new Signature("not", SCALAR, parseTypeSignature(StandardTypes.BOOLEAN), ImmutableList.of(parseTypeSignature(StandardTypes.BOOLEAN))); }
@Test public void testArray() { InternalAggregationFunction varcharAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("array_agg", AGGREGATE, parseTypeSignature("array(array(bigint))"), parseTypeSignature("array(bigint)"))); assertAggregation( varcharAgg, Arrays.asList(Arrays.asList(1L), Arrays.asList(1L, 2L), Arrays.asList(1L, 2L, 3L)), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(1L), ImmutableList.of(1L, 2L), ImmutableList.of(1L, 2L, 3L)))); }
@Test public void testNoCaching() { ImmutableList.Builder<RowExpression> projectionsBuilder = ImmutableList.builder(); ArrayType arrayType = new ArrayType(VARCHAR); Signature signature = new Signature("concat", SCALAR, arrayType.getTypeSignature(), arrayType.getTypeSignature(), arrayType.getTypeSignature()); projectionsBuilder.add(new CallExpression(signature, arrayType, ImmutableList.of(field(0, arrayType), field(1, arrayType)))); ImmutableList<RowExpression> projections = projectionsBuilder.build(); PageProcessor pageProcessor = compiler.compilePageProcessor(Optional.empty(), projections).get(); PageProcessor pageProcessor2 = compiler.compilePageProcessor(Optional.empty(), projections).get(); assertTrue(pageProcessor != pageProcessor2); }
@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); }
@Override protected List<? extends OperatorFactory> createOperatorFactories() { OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderkey"); InternalAggregationFunction countFunction = localQueryRunner.getMetadata().getFunctionRegistry().getAggregateFunctionImplementation( new Signature("count", AGGREGATE, BIGINT.getTypeSignature())); AggregationOperatorFactory aggregationOperator = new AggregationOperatorFactory(1, new PlanNodeId("test"), Step.SINGLE, ImmutableList.of(countFunction.bind(ImmutableList.of(0), Optional.empty())), false); return ImmutableList.of(tableScanOperator, aggregationOperator); }
@Test public void testValidArray() { InternalAggregationFunction arrayAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("arbitrary", AGGREGATE, parseTypeSignature("array(bigint)"), parseTypeSignature("array(bigint)"))); assertAggregation( arrayAgg, ImmutableList.of(23L, 45L), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(23L, 45L), ImmutableList.of(23L, 45L), ImmutableList.of(23L, 45L), ImmutableList.of(23L, 45L)))); }
public ElementToArrayConcatFunction() { super(new Signature( FUNCTION_NAME, FunctionKind.SCALAR, ImmutableList.of(typeVariable("E")), ImmutableList.of(), parseTypeSignature("array(E)"), ImmutableList.of(parseTypeSignature("E"), parseTypeSignature("array(E)")), false)); }
@Test public void testValidBoolean() { InternalAggregationFunction booleanAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("arbitrary", AGGREGATE, parseTypeSignature(StandardTypes.BOOLEAN), parseTypeSignature(StandardTypes.BOOLEAN))); assertAggregation( booleanAgg, true, createBooleansBlock(true, true)); }
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"); }
private static RowExpression ifExpression(RowExpression condition, long trueValue, long falseValue) { Signature signature = new Signature("IF", SCALAR, BIGINT.getTypeSignature(), BOOLEAN.getTypeSignature(), BIGINT.getTypeSignature(), BIGINT.getTypeSignature()); return new CallExpression(signature, BIGINT, ImmutableList.of(condition, constant(trueValue, BIGINT), constant(falseValue, BIGINT))); } }
@Test public void testValidLong() { InternalAggregationFunction longAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("arbitrary", AGGREGATE, parseTypeSignature(StandardTypes.BIGINT), parseTypeSignature(StandardTypes.BIGINT))); assertAggregation( longAgg, 1L, createLongsBlock(1L, null)); }
public ArrayJoin() { super(new Signature(FUNCTION_NAME, FunctionKind.SCALAR, ImmutableList.of(typeVariable("T")), ImmutableList.of(), parseTypeSignature(StandardTypes.VARCHAR), ImmutableList.of(parseTypeSignature("array(T)"), parseTypeSignature(StandardTypes.VARCHAR)), false)); }
@Test public void testValidDouble() { InternalAggregationFunction doubleAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("arbitrary", AGGREGATE, parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE))); assertAggregation( doubleAgg, 2.0, createDoublesBlock(null, 2.0)); }
private JsonStringToRowCast() { super(new Signature( JSON_STRING_TO_ROW_NAME, SCALAR, ImmutableList.of(withVariadicBound("T", "row")), ImmutableList.of(), parseTypeSignature("T"), ImmutableList.of(parseTypeSignature(StandardTypes.VARCHAR)), false)); }
@Test public void testValidInt() { InternalAggregationFunction arrayAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("arbitrary", AGGREGATE, parseTypeSignature("integer"), parseTypeSignature("integer"))); assertAggregation( arrayAgg, 3, createIntsBlock(3, 3, null)); } }
private ArrayFlattenFunction() { super(new Signature(FUNCTION_NAME, FunctionKind.SCALAR, ImmutableList.of(typeVariable("E")), ImmutableList.of(), parseTypeSignature("array(E)"), ImmutableList.of(parseTypeSignature("array(array(E))")), false)); }
@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})); }
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)); }