private static void extractParametricScalar(Class<?> clazz) { new FunctionListBuilder().scalar(clazz); }
.aggregates(BitwiseOrAggregation.class) .aggregates(BitwiseAndAggregation.class) .scalar(RepeatFunction.class) .scalars(SequenceFunction.class) .scalars(SessionFunctions.class) .scalars(StringFunctions.class) .scalars(WordStemFunction.class) .scalar(SplitToMapFunction.class) .scalar(SplitToMultimapFunction.class) .scalars(VarbinaryFunctions.class) .scalars(UrlFunctions.class) .scalars(MathFunctions.class) .scalar(MathFunctions.Abs.class) .scalar(MathFunctions.Sign.class) .scalar(MathFunctions.Round.class) .scalar(MathFunctions.RoundN.class) .scalar(MathFunctions.Truncate.class) .scalar(MathFunctions.TruncateN.class) .scalar(MathFunctions.Ceiling.class) .scalar(MathFunctions.Floor.class) .scalars(BitwiseFunctions.class) .scalars(DateTimeFunctions.class) .scalars(ColorFunctions.class) .scalars(ColorOperators.class) .scalar(ColorOperators.ColorDistinctFromOperator.class) .scalars(HyperLogLogFunctions.class) .scalars(QuantileDigestFunctions.class) .scalars(UnknownOperators.class)
protected void registerParametricScalar(Class<?> clazz) { Metadata metadata = functionAssertions.getMetadata(); List<SqlFunction> functions = new FunctionListBuilder() .scalar(clazz) .getFunctions(); metadata.getFunctionRegistry().addFunctions(functions); }
metadata.addFunctions(new FunctionListBuilder().scalar(BenchmarkOldArrayHash.class).getFunctions()); metadata.addFunctions(new FunctionListBuilder().scalar(BenchmarkAnotherArrayHash.class).getFunctions()); ExpressionCompiler compiler = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0)); ImmutableList.Builder<RowExpression> projectionsBuilder = ImmutableList.builder();
if (clazz.getName().startsWith("com.qubole.presto.udfs.scalar")) { try { builder.scalar(clazz);
.aggregate(RegressionAggregation.class) .aggregate(CorrelationAggregation.class) .scalar(StringFunctions.class) .scalar(VarbinaryFunctions.class) .scalar(RegexpFunctions.class) .scalar(UrlFunctions.class) .scalar(MathFunctions.class) .scalar(BitwiseFunctions.class) .scalar(DateTimeFunctions.class) .scalar(JsonFunctions.class) .scalar(ColorFunctions.class) .scalar(ColorOperators.class) .scalar(HyperLogLogFunctions.class) .scalar(UnknownOperators.class) .scalar(BooleanOperators.class) .scalar(BigintOperators.class) .scalar(DoubleOperators.class) .scalar(VarcharOperators.class) .scalar(VarbinaryOperators.class) .scalar(DateOperators.class) .scalar(TimeOperators.class) .scalar(TimestampOperators.class) .scalar(IntervalDayTimeOperators.class) .scalar(IntervalYearMonthOperators.class) .scalar(TimeWithTimeZoneOperators.class) .scalar(TimestampWithTimeZoneOperators.class) .scalar(DateTimeOperators.class) .scalar(HyperLogLogOperators.class) .scalar(LikeFunctions.class)
public FunctionAssertions addScalarFunctions(Class<?> clazz) { metadata.addFunctions(new FunctionListBuilder(metadata.getTypeManager()).scalar(clazz).getFunctions()); return this; }
@Setup public void setup() { MetadataManager metadata = MetadataManager.createTestMetadataManager(); metadata.addFunctions(new FunctionListBuilder(metadata.getTypeManager()).scalar(BenchmarkArrayDistinct.class).getFunctions()); ExpressionCompiler compiler = new ExpressionCompiler(metadata); ImmutableList.Builder<RowExpression> projectionsBuilder = ImmutableList.builder(); Block[] blocks = new Block[TYPES.size()]; for (int i = 0; i < TYPES.size(); i++) { Type elementType = TYPES.get(i); ArrayType arrayType = new ArrayType(elementType); Signature signature = new Signature(name, FunctionKind.SCALAR, arrayType.getTypeSignature(), arrayType.getTypeSignature()); projectionsBuilder.add(new CallExpression(signature, arrayType, ImmutableList.of(new InputReferenceExpression(i, arrayType)))); blocks[i] = createChannel(POSITIONS, ARRAY_SIZE, arrayType); } ImmutableList<RowExpression> projections = projectionsBuilder.build(); pageProcessor = compiler.compilePageProcessor(new ConstantExpression(true, BooleanType.BOOLEAN), projections).get(); pageBuilder = new PageBuilder(projections.stream().map(RowExpression::getType).collect(Collectors.toList())); page = new Page(blocks); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "\\QFunction already registered: custom_add(bigint,bigint):bigint\\E") public void testDuplicateFunctions() { List<SqlFunction> functions = new FunctionListBuilder(new TypeRegistry()) .scalar(CustomFunctions.class) .getFunctions() .stream() .filter(input -> input.getSignature().getName().equals("custom_add")) .collect(toImmutableList()); TypeRegistry typeManager = new TypeRegistry(); FunctionRegistry registry = new FunctionRegistry(typeManager, new BlockEncodingManager(typeManager), true); registry.addFunctions(functions); registry.addFunctions(functions); }
protected void registerScalar(Class<?> clazz) { Metadata metadata = functionAssertions.getMetadata(); List<SqlFunction> functions = new FunctionListBuilder(metadata.getTypeManager()) .scalar(clazz) .getFunctions(); metadata.getFunctionRegistry().addFunctions(functions); }
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "'sum' is both an aggregation and a scalar function") public void testConflictingScalarAggregation() throws Exception { List<SqlFunction> functions = new FunctionListBuilder(new TypeRegistry()) .scalar(ScalarSum.class) .getFunctions(); TypeRegistry typeManager = new TypeRegistry(); FunctionRegistry registry = new FunctionRegistry(typeManager, new BlockEncodingManager(typeManager), true); registry.addFunctions(functions); }