Search in sources :

Example 6 with Signature

use of com.facebook.presto.metadata.Signature in project presto by prestodb.

the class CastCodeGenerator method generateExpression.

@Override
public BytecodeNode generateExpression(Signature signature, BytecodeGeneratorContext generatorContext, Type returnType, List<RowExpression> arguments) {
    RowExpression argument = arguments.get(0);
    Signature function = generatorContext.getRegistry().getCoercion(argument.getType(), returnType);
    return generatorContext.generateCall(function.getName(), generatorContext.getRegistry().getScalarFunctionImplementation(function), ImmutableList.of(generatorContext.generate(argument)));
}
Also used : Signature(com.facebook.presto.metadata.Signature) RowExpression(com.facebook.presto.sql.relational.RowExpression)

Example 7 with Signature

use of com.facebook.presto.metadata.Signature in project presto by prestodb.

the class QueryPlanner method aggregate.

private PlanBuilder aggregate(PlanBuilder subPlan, QuerySpecification node) {
    List<List<Expression>> groupingSets = analysis.getGroupingSets(node);
    if (groupingSets.isEmpty()) {
        return subPlan;
    }
    // 1. Pre-project all scalar inputs (arguments and non-trivial group by expressions)
    Set<Expression> distinctGroupingColumns = groupingSets.stream().flatMap(Collection::stream).collect(toImmutableSet());
    ImmutableList.Builder<Expression> arguments = ImmutableList.builder();
    analysis.getAggregates(node).stream().map(FunctionCall::getArguments).flatMap(List::stream).forEach(arguments::add);
    // filter expressions need to be projected first
    analysis.getAggregates(node).stream().map(FunctionCall::getFilter).filter(Optional::isPresent).map(Optional::get).forEach(arguments::add);
    Iterable<Expression> inputs = Iterables.concat(distinctGroupingColumns, arguments.build());
    subPlan = handleSubqueries(subPlan, node, inputs);
    if (!Iterables.isEmpty(inputs)) {
        // avoid an empty projection if the only aggregation is COUNT (which has no arguments)
        subPlan = project(subPlan, inputs);
    }
    // 2. Aggregate
    // 2.a. Rewrite aggregate arguments
    TranslationMap argumentTranslations = new TranslationMap(subPlan.getRelationPlan(), analysis, lambdaDeclarationToSymbolMap);
    ImmutableMap.Builder<Symbol, Symbol> argumentMappingBuilder = ImmutableMap.builder();
    for (Expression argument : arguments.build()) {
        Expression parametersReplaced = ExpressionTreeRewriter.rewriteWith(new ParameterRewriter(analysis.getParameters(), analysis), argument);
        argumentTranslations.addIntermediateMapping(argument, parametersReplaced);
        Symbol input = subPlan.translate(parametersReplaced);
        if (!argumentTranslations.containsSymbol(parametersReplaced)) {
            Symbol output = symbolAllocator.newSymbol(parametersReplaced, analysis.getTypeWithCoercions(parametersReplaced), "arg");
            argumentMappingBuilder.put(output, input);
            argumentTranslations.put(parametersReplaced, output);
        }
    }
    Map<Symbol, Symbol> argumentMappings = argumentMappingBuilder.build();
    // 2.b. Rewrite grouping columns
    TranslationMap groupingTranslations = new TranslationMap(subPlan.getRelationPlan(), analysis, lambdaDeclarationToSymbolMap);
    Map<Symbol, Symbol> groupingSetMappings = new HashMap<>();
    List<List<Symbol>> groupingSymbols = new ArrayList<>();
    for (List<Expression> groupingSet : groupingSets) {
        ImmutableList.Builder<Symbol> symbols = ImmutableList.builder();
        for (Expression expression : groupingSet) {
            Expression parametersReplaced = ExpressionTreeRewriter.rewriteWith(new ParameterRewriter(analysis.getParameters(), analysis), expression);
            groupingTranslations.addIntermediateMapping(expression, parametersReplaced);
            Symbol input = subPlan.translate(expression);
            Symbol output;
            if (!groupingTranslations.containsSymbol(parametersReplaced)) {
                output = symbolAllocator.newSymbol(parametersReplaced, analysis.getTypeWithCoercions(expression), "gid");
                groupingTranslations.put(parametersReplaced, output);
            } else {
                output = groupingTranslations.get(parametersReplaced);
            }
            groupingSetMappings.put(output, input);
            symbols.add(output);
        }
        groupingSymbols.add(symbols.build());
    }
    // 2.c. Generate GroupIdNode (multiple grouping sets) or ProjectNode (single grouping set)
    Optional<Symbol> groupIdSymbol = Optional.empty();
    if (groupingSets.size() > 1) {
        groupIdSymbol = Optional.of(symbolAllocator.newSymbol("groupId", BIGINT));
        GroupIdNode groupId = new GroupIdNode(idAllocator.getNextId(), subPlan.getRoot(), groupingSymbols, groupingSetMappings, argumentMappings, groupIdSymbol.get());
        subPlan = new PlanBuilder(groupingTranslations, groupId, analysis.getParameters());
    } else {
        Assignments.Builder assignments = Assignments.builder();
        for (Symbol output : argumentMappings.keySet()) {
            assignments.put(output, argumentMappings.get(output).toSymbolReference());
        }
        for (Symbol output : groupingSetMappings.keySet()) {
            assignments.put(output, groupingSetMappings.get(output).toSymbolReference());
        }
        ProjectNode project = new ProjectNode(idAllocator.getNextId(), subPlan.getRoot(), assignments.build());
        subPlan = new PlanBuilder(groupingTranslations, project, analysis.getParameters());
    }
    TranslationMap aggregationTranslations = new TranslationMap(subPlan.getRelationPlan(), analysis, lambdaDeclarationToSymbolMap);
    aggregationTranslations.copyMappingsFrom(groupingTranslations);
    // 2.d. Rewrite aggregates
    ImmutableMap.Builder<Symbol, FunctionCall> aggregationAssignments = ImmutableMap.builder();
    ImmutableMap.Builder<Symbol, Signature> functions = ImmutableMap.builder();
    boolean needPostProjectionCoercion = false;
    for (FunctionCall aggregate : analysis.getAggregates(node)) {
        Expression parametersReplaced = ExpressionTreeRewriter.rewriteWith(new ParameterRewriter(analysis.getParameters(), analysis), aggregate);
        aggregationTranslations.addIntermediateMapping(aggregate, parametersReplaced);
        Expression rewritten = argumentTranslations.rewrite(parametersReplaced);
        Symbol newSymbol = symbolAllocator.newSymbol(rewritten, analysis.getType(aggregate));
        // Therefore we can end up with this implicit cast, and have to move it into a post-projection
        if (rewritten instanceof Cast) {
            rewritten = ((Cast) rewritten).getExpression();
            needPostProjectionCoercion = true;
        }
        aggregationAssignments.put(newSymbol, (FunctionCall) rewritten);
        aggregationTranslations.put(parametersReplaced, newSymbol);
        functions.put(newSymbol, analysis.getFunctionSignature(aggregate));
    }
    // 2.e. Mark distinct rows for each aggregate that has DISTINCT
    // Map from aggregate function arguments to marker symbols, so that we can reuse the markers, if two aggregates have the same argument
    Map<Set<Expression>, Symbol> argumentMarkers = new HashMap<>();
    // Map from aggregate functions to marker symbols
    Map<Symbol, Symbol> masks = new HashMap<>();
    for (FunctionCall aggregate : Iterables.filter(analysis.getAggregates(node), FunctionCall::isDistinct)) {
        Set<Expression> args = ImmutableSet.copyOf(aggregate.getArguments());
        Symbol marker = argumentMarkers.get(args);
        Symbol aggregateSymbol = aggregationTranslations.get(aggregate);
        if (marker == null) {
            if (args.size() == 1) {
                marker = symbolAllocator.newSymbol(getOnlyElement(args), BOOLEAN, "distinct");
            } else {
                marker = symbolAllocator.newSymbol(aggregateSymbol.getName(), BOOLEAN, "distinct");
            }
            argumentMarkers.put(args, marker);
        }
        masks.put(aggregateSymbol, marker);
    }
    for (Map.Entry<Set<Expression>, Symbol> entry : argumentMarkers.entrySet()) {
        ImmutableList.Builder<Symbol> builder = ImmutableList.builder();
        builder.addAll(groupingSymbols.stream().flatMap(Collection::stream).distinct().collect(Collectors.toList()));
        groupIdSymbol.ifPresent(builder::add);
        for (Expression expression : entry.getKey()) {
            builder.add(argumentTranslations.get(expression));
        }
        subPlan = subPlan.withNewRoot(new MarkDistinctNode(idAllocator.getNextId(), subPlan.getRoot(), entry.getValue(), builder.build(), Optional.empty()));
    }
    AggregationNode aggregationNode = new AggregationNode(idAllocator.getNextId(), subPlan.getRoot(), aggregationAssignments.build(), functions.build(), masks, groupingSymbols, AggregationNode.Step.SINGLE, Optional.empty(), groupIdSymbol);
    subPlan = new PlanBuilder(aggregationTranslations, aggregationNode, analysis.getParameters());
    // TODO: this is a hack, we should change type coercions to coerce the inputs to functions/operators instead of coercing the output
    if (needPostProjectionCoercion) {
        return explicitCoercionFields(subPlan, distinctGroupingColumns, analysis.getAggregates(node));
    }
    return subPlan;
}
Also used : Cast(com.facebook.presto.sql.tree.Cast) ImmutableCollectors.toImmutableSet(com.facebook.presto.util.ImmutableCollectors.toImmutableSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IdentityLinkedHashMap(com.facebook.presto.util.maps.IdentityLinkedHashMap) ImmutableList(com.google.common.collect.ImmutableList) ArrayList(java.util.ArrayList) Assignments(com.facebook.presto.sql.planner.plan.Assignments) GroupIdNode(com.facebook.presto.sql.planner.plan.GroupIdNode) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) FunctionCall(com.facebook.presto.sql.tree.FunctionCall) MarkDistinctNode(com.facebook.presto.sql.planner.plan.MarkDistinctNode) Optional(java.util.Optional) AggregationNode(com.facebook.presto.sql.planner.plan.AggregationNode) ImmutableMap(com.google.common.collect.ImmutableMap) Expression(com.facebook.presto.sql.tree.Expression) Signature(com.facebook.presto.metadata.Signature) ProjectNode(com.facebook.presto.sql.planner.plan.ProjectNode) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IdentityLinkedHashMap(com.facebook.presto.util.maps.IdentityLinkedHashMap)

Example 8 with Signature

use of com.facebook.presto.metadata.Signature in project presto by prestodb.

the class DecimalCasts method castFunctionFromDecimalTo.

private static SqlScalarFunction castFunctionFromDecimalTo(TypeSignature to, String... methodNames) {
    Signature signature = Signature.builder().kind(SCALAR).operatorType(CAST).argumentTypes(parseTypeSignature("decimal(precision,scale)", ImmutableSet.of("precision", "scale"))).returnType(to).build();
    return SqlScalarFunction.builder(DecimalCasts.class).signature(signature).implementation(b -> b.methods(methodNames).withExtraParameters((context) -> {
        long precision = context.getLiteral("precision");
        long scale = context.getLiteral("scale");
        Number tenToScale;
        if (isShortDecimal(context.getParameterTypes().get(0))) {
            tenToScale = longTenToNth(intScale(scale));
        } else {
            tenToScale = bigIntegerTenToNth(intScale(scale));
        }
        return ImmutableList.of(precision, scale, tenToScale);
    })).build();
}
Also used : CAST(com.facebook.presto.spi.function.OperatorType.CAST) Decimals.encodeUnscaledValue(com.facebook.presto.spi.type.Decimals.encodeUnscaledValue) UnscaledDecimal128Arithmetic.unscaledDecimalToUnscaledLongUnsafe(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.unscaledDecimalToUnscaledLongUnsafe) BIGINT(com.facebook.presto.spi.type.BigintType.BIGINT) BigDecimal(java.math.BigDecimal) Float.parseFloat(java.lang.Float.parseFloat) DecimalType(com.facebook.presto.spi.type.DecimalType) BOOLEAN(com.facebook.presto.spi.type.BooleanType.BOOLEAN) Slices(io.airlift.slice.Slices) Decimals.decodeUnscaledValue(com.facebook.presto.spi.type.Decimals.decodeUnscaledValue) BigInteger(java.math.BigInteger) StandardTypes(com.facebook.presto.spi.type.StandardTypes) UsedByGeneratedCode(com.facebook.presto.annotation.UsedByGeneratedCode) Double.parseDouble(java.lang.Double.parseDouble) UnscaledDecimal128Arithmetic(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic) Decimals.isShortDecimal(com.facebook.presto.spi.type.Decimals.isShortDecimal) Decimals(com.facebook.presto.spi.type.Decimals) TINYINT(com.facebook.presto.spi.type.TinyintType.TINYINT) ImmutableSet(com.google.common.collect.ImmutableSet) UnscaledDecimal128Arithmetic.multiply(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.multiply) String.format(java.lang.String.format) Preconditions.checkState(com.google.common.base.Preconditions.checkState) UnscaledDecimal128Arithmetic.compareAbsolute(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.compareAbsolute) INTEGER(com.facebook.presto.spi.type.IntegerType.INTEGER) ZERO(java.math.BigInteger.ZERO) Decimals.longTenToNth(com.facebook.presto.spi.type.Decimals.longTenToNth) TypeSignature(com.facebook.presto.spi.type.TypeSignature) UnscaledDecimal128Arithmetic.rescale(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.rescale) DOUBLE(com.facebook.presto.spi.type.DoubleType.DOUBLE) Slice(io.airlift.slice.Slice) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) SliceOutput(io.airlift.slice.SliceOutput) JSON(com.facebook.presto.type.JsonType.JSON) Shorts(com.google.common.primitives.Shorts) UnscaledDecimal128Arithmetic.unscaledDecimalToUnscaledLong(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.unscaledDecimalToUnscaledLong) PrestoException(com.facebook.presto.spi.PrestoException) Float.intBitsToFloat(java.lang.Float.intBitsToFloat) DynamicSliceOutput(io.airlift.slice.DynamicSliceOutput) Float.floatToRawIntBits(java.lang.Float.floatToRawIntBits) SCALAR(com.facebook.presto.metadata.FunctionKind.SCALAR) JsonUtil.createJsonGenerator(com.facebook.presto.util.JsonUtil.createJsonGenerator) UnscaledDecimal128Arithmetic.overflows(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.overflows) ImmutableList(com.google.common.collect.ImmutableList) JsonUtil.createJsonParser(com.facebook.presto.util.JsonUtil.createJsonParser) Math.toIntExact(java.lang.Math.toIntExact) Nullable(javax.annotation.Nullable) Failures.checkCondition(com.facebook.presto.util.Failures.checkCondition) Decimals.bigIntegerTenToNth(com.facebook.presto.spi.type.Decimals.bigIntegerTenToNth) JsonParser(com.fasterxml.jackson.core.JsonParser) SqlScalarFunction(com.facebook.presto.metadata.SqlScalarFunction) HALF_UP(java.math.RoundingMode.HALF_UP) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Signature(com.facebook.presto.metadata.Signature) SignedBytes(com.google.common.primitives.SignedBytes) INVALID_CAST_ARGUMENT(com.facebook.presto.spi.StandardErrorCode.INVALID_CAST_ARGUMENT) IOException(java.io.IOException) SMALLINT(com.facebook.presto.spi.type.SmallintType.SMALLINT) JSON_FACTORY(com.facebook.presto.operator.scalar.JsonOperators.JSON_FACTORY) UnscaledDecimal128Arithmetic.unscaledDecimal(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.unscaledDecimal) Math.multiplyExact(java.lang.Math.multiplyExact) REAL(com.facebook.presto.spi.type.RealType.REAL) SqlScalarFunctionBuilder(com.facebook.presto.metadata.SqlScalarFunctionBuilder) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Decimals.overflows(com.facebook.presto.spi.type.Decimals.overflows) TypeSignature(com.facebook.presto.spi.type.TypeSignature) Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)

Example 9 with Signature

use of com.facebook.presto.metadata.Signature in project presto by prestodb.

the class DecimalOperators method decimalSubtractOperator.

private static SqlScalarFunction decimalSubtractOperator() {
    TypeSignature decimalLeftSignature = parseTypeSignature("decimal(a_precision, a_scale)", ImmutableSet.of("a_precision", "a_scale"));
    TypeSignature decimalRightSignature = parseTypeSignature("decimal(b_precision, b_scale)", ImmutableSet.of("b_precision", "b_scale"));
    TypeSignature decimalResultSignature = parseTypeSignature("decimal(r_precision, r_scale)", ImmutableSet.of("r_precision", "r_scale"));
    Signature signature = Signature.builder().kind(SCALAR).operatorType(SUBTRACT).longVariableConstraints(longVariableExpression("r_precision", "min(38, max(a_precision - a_scale, b_precision - b_scale) + max(a_scale, b_scale) + 1)"), longVariableExpression("r_scale", "max(a_scale, b_scale)")).argumentTypes(decimalLeftSignature, decimalRightSignature).returnType(decimalResultSignature).build();
    return SqlScalarFunction.builder(DecimalOperators.class).signature(signature).implementation(b -> b.methods("subtractShortShortShort").withExtraParameters(DecimalOperators::calculateShortRescaleParameters)).implementation(b -> b.methods("subtractShortShortLong", "subtractLongLongLong", "subtractShortLongLong", "subtractLongShortLong").withExtraParameters(DecimalOperators::calculateLongRescaleParameters)).build();
}
Also used : SpecializeContext(com.facebook.presto.metadata.SqlScalarFunctionBuilder.SpecializeContext) TypeSignature(com.facebook.presto.spi.type.TypeSignature) UnscaledDecimal128Arithmetic.rescale(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.rescale) MULTIPLY(com.facebook.presto.spi.function.OperatorType.MULTIPLY) Slice(io.airlift.slice.Slice) UnscaledDecimal128Arithmetic.divideRoundUp(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.divideRoundUp) UnscaledDecimal128Arithmetic.throwIfOverflows(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.throwIfOverflows) DIVISION_BY_ZERO(com.facebook.presto.spi.StandardErrorCode.DIVISION_BY_ZERO) HASH_CODE(com.facebook.presto.spi.function.OperatorType.HASH_CODE) Decimals.encodeUnscaledValue(com.facebook.presto.spi.type.Decimals.encodeUnscaledValue) UnscaledDecimal128Arithmetic.unscaledDecimalToUnscaledLong(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.unscaledDecimalToUnscaledLong) Math.abs(java.lang.Math.abs) PrestoException(com.facebook.presto.spi.PrestoException) SCALAR(com.facebook.presto.metadata.FunctionKind.SCALAR) Signature.longVariableExpression(com.facebook.presto.metadata.Signature.longVariableExpression) MODULUS(com.facebook.presto.spi.function.OperatorType.MODULUS) ScalarOperator(com.facebook.presto.spi.function.ScalarOperator) DecimalType(com.facebook.presto.spi.type.DecimalType) ImmutableList(com.google.common.collect.ImmutableList) Objects.requireNonNull(java.util.Objects.requireNonNull) BigInteger(java.math.BigInteger) Math.toIntExact(java.lang.Math.toIntExact) LiteralParameters(com.facebook.presto.spi.function.LiteralParameters) UsedByGeneratedCode(com.facebook.presto.annotation.UsedByGeneratedCode) UnscaledDecimal128Arithmetic(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic) Long.signum(java.lang.Long.signum) Decimals(com.facebook.presto.spi.type.Decimals) ImmutableSet(com.google.common.collect.ImmutableSet) DIVIDE(com.facebook.presto.spi.function.OperatorType.DIVIDE) SqlScalarFunction(com.facebook.presto.metadata.SqlScalarFunction) Signature(com.facebook.presto.metadata.Signature) UnscaledDecimal128Arithmetic.isZero(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.isZero) UnscaledDecimal128Arithmetic.unscaledDecimal(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.unscaledDecimal) NEGATION(com.facebook.presto.spi.function.OperatorType.NEGATION) Integer.max(java.lang.Integer.max) List(java.util.List) NUMERIC_VALUE_OUT_OF_RANGE(com.facebook.presto.spi.StandardErrorCode.NUMERIC_VALUE_OUT_OF_RANGE) UnscaledDecimal128Arithmetic.remainder(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.remainder) SqlScalarFunctionBuilder(com.facebook.presto.metadata.SqlScalarFunctionBuilder) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) SignatureBuilder(com.facebook.presto.metadata.SignatureBuilder) SUBTRACT(com.facebook.presto.spi.function.OperatorType.SUBTRACT) SqlType(com.facebook.presto.spi.function.SqlType) Decimals.longTenToNth(com.facebook.presto.spi.type.Decimals.longTenToNth) ADD(com.facebook.presto.spi.function.OperatorType.ADD) TypeSignature(com.facebook.presto.spi.type.TypeSignature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) TypeSignature(com.facebook.presto.spi.type.TypeSignature) Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)

Example 10 with Signature

use of com.facebook.presto.metadata.Signature in project presto by prestodb.

the class DecimalOperators method decimalDivideOperator.

private static SqlScalarFunction decimalDivideOperator() {
    TypeSignature decimalLeftSignature = parseTypeSignature("decimal(a_precision, a_scale)", ImmutableSet.of("a_precision", "a_scale"));
    TypeSignature decimalRightSignature = parseTypeSignature("decimal(b_precision, b_scale)", ImmutableSet.of("b_precision", "b_scale"));
    TypeSignature decimalResultSignature = parseTypeSignature("decimal(r_precision, r_scale)", ImmutableSet.of("r_precision", "r_scale"));
    // we extend target precision by b_scale. This is upper bound on how much division result will grow.
    // pessimistic case is a / 0.0000001
    // if scale of divisor is greater than scale of dividend we extend scale further as we
    // want result scale to be maximum of scales of divisor and dividend.
    Signature signature = Signature.builder().kind(SCALAR).operatorType(DIVIDE).longVariableConstraints(longVariableExpression("r_precision", "min(38, a_precision + b_scale + max(b_scale - a_scale, 0))"), longVariableExpression("r_scale", "max(a_scale, b_scale)")).argumentTypes(decimalLeftSignature, decimalRightSignature).returnType(decimalResultSignature).build();
    return SqlScalarFunction.builder(DecimalOperators.class).signature(signature).implementation(b -> b.methods("divideShortShortShort", "divideShortLongShort", "divideLongShortShort", "divideShortShortLong", "divideLongLongLong", "divideShortLongLong", "divideLongShortLong").withExtraParameters(DecimalOperators::divideRescaleFactor)).build();
}
Also used : SpecializeContext(com.facebook.presto.metadata.SqlScalarFunctionBuilder.SpecializeContext) TypeSignature(com.facebook.presto.spi.type.TypeSignature) UnscaledDecimal128Arithmetic.rescale(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.rescale) MULTIPLY(com.facebook.presto.spi.function.OperatorType.MULTIPLY) Slice(io.airlift.slice.Slice) UnscaledDecimal128Arithmetic.divideRoundUp(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.divideRoundUp) UnscaledDecimal128Arithmetic.throwIfOverflows(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.throwIfOverflows) DIVISION_BY_ZERO(com.facebook.presto.spi.StandardErrorCode.DIVISION_BY_ZERO) HASH_CODE(com.facebook.presto.spi.function.OperatorType.HASH_CODE) Decimals.encodeUnscaledValue(com.facebook.presto.spi.type.Decimals.encodeUnscaledValue) UnscaledDecimal128Arithmetic.unscaledDecimalToUnscaledLong(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.unscaledDecimalToUnscaledLong) Math.abs(java.lang.Math.abs) PrestoException(com.facebook.presto.spi.PrestoException) SCALAR(com.facebook.presto.metadata.FunctionKind.SCALAR) Signature.longVariableExpression(com.facebook.presto.metadata.Signature.longVariableExpression) MODULUS(com.facebook.presto.spi.function.OperatorType.MODULUS) ScalarOperator(com.facebook.presto.spi.function.ScalarOperator) DecimalType(com.facebook.presto.spi.type.DecimalType) ImmutableList(com.google.common.collect.ImmutableList) Objects.requireNonNull(java.util.Objects.requireNonNull) BigInteger(java.math.BigInteger) Math.toIntExact(java.lang.Math.toIntExact) LiteralParameters(com.facebook.presto.spi.function.LiteralParameters) UsedByGeneratedCode(com.facebook.presto.annotation.UsedByGeneratedCode) UnscaledDecimal128Arithmetic(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic) Long.signum(java.lang.Long.signum) Decimals(com.facebook.presto.spi.type.Decimals) ImmutableSet(com.google.common.collect.ImmutableSet) DIVIDE(com.facebook.presto.spi.function.OperatorType.DIVIDE) SqlScalarFunction(com.facebook.presto.metadata.SqlScalarFunction) Signature(com.facebook.presto.metadata.Signature) UnscaledDecimal128Arithmetic.isZero(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.isZero) UnscaledDecimal128Arithmetic.unscaledDecimal(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.unscaledDecimal) NEGATION(com.facebook.presto.spi.function.OperatorType.NEGATION) Integer.max(java.lang.Integer.max) List(java.util.List) NUMERIC_VALUE_OUT_OF_RANGE(com.facebook.presto.spi.StandardErrorCode.NUMERIC_VALUE_OUT_OF_RANGE) UnscaledDecimal128Arithmetic.remainder(com.facebook.presto.spi.type.UnscaledDecimal128Arithmetic.remainder) SqlScalarFunctionBuilder(com.facebook.presto.metadata.SqlScalarFunctionBuilder) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) SignatureBuilder(com.facebook.presto.metadata.SignatureBuilder) SUBTRACT(com.facebook.presto.spi.function.OperatorType.SUBTRACT) SqlType(com.facebook.presto.spi.function.SqlType) Decimals.longTenToNth(com.facebook.presto.spi.type.Decimals.longTenToNth) ADD(com.facebook.presto.spi.function.OperatorType.ADD) TypeSignature(com.facebook.presto.spi.type.TypeSignature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) TypeSignature(com.facebook.presto.spi.type.TypeSignature) Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)

Aggregations

Signature (com.facebook.presto.metadata.Signature)123 TypeSignature.parseTypeSignature (com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)96 Test (org.testng.annotations.Test)91 MapType (com.facebook.presto.type.MapType)18 ImmutableList (com.google.common.collect.ImmutableList)16 RowExpression (com.facebook.presto.sql.relational.RowExpression)12 TypeSignature (com.facebook.presto.spi.type.TypeSignature)11 FunctionCall (com.facebook.presto.sql.tree.FunctionCall)11 Block (com.facebook.presto.spi.block.Block)10 Type (com.facebook.presto.spi.type.Type)10 InternalAggregationFunction (com.facebook.presto.operator.aggregation.InternalAggregationFunction)8 Page (com.facebook.presto.spi.Page)8 DecimalType (com.facebook.presto.spi.type.DecimalType)8 CallExpression (com.facebook.presto.sql.relational.CallExpression)8 MethodHandle (java.lang.invoke.MethodHandle)8 MetadataManager (com.facebook.presto.metadata.MetadataManager)7 PlanNode (com.facebook.presto.sql.planner.plan.PlanNode)7 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)7 ConstantExpression (com.facebook.presto.sql.relational.ConstantExpression)7 BlockBuilder (com.facebook.presto.spi.block.BlockBuilder)6