Refine search
public static FunctionCall getCall(CurrentPath node) { return new FunctionCall(QualifiedName.of("$current_path"), ImmutableList.of()); } }
public static Expression functionCall(String name, Expression... arguments) { return new FunctionCall(QualifiedName.of(name), ImmutableList.copyOf(arguments)); }
private ColumnStatisticsAggregation createAggregation(QualifiedName functionName, SymbolReference input, Type inputType, Type outputType) { Signature signature = metadata.getFunctionRegistry().resolveFunction(functionName, TypeSignatureProvider.fromTypes(ImmutableList.of(inputType))); Type resolvedType = metadata.getType(getOnlyElement(signature.getArgumentTypes())); verify(resolvedType.equals(inputType), "resolved function input type does not match the input type: %s != %s", resolvedType, inputType); return new ColumnStatisticsAggregation( new AggregationNode.Aggregation( new FunctionCall(functionName, ImmutableList.of(input)), signature, Optional.empty()), outputType); }
public static FunctionCall getCall(CurrentUser node) { return new FunctionCall(QualifiedName.of("$current_user"), ImmutableList.of()); } }
List<Expression> outputColumnReferences = ImmutableList.of(outputColumn.toSymbolReference()); List<TypeSignature> outputColumnTypeSignature = ImmutableList.of(outputColumnType.getTypeSignature()); ImmutableMap.of( minValue, new Aggregation( new FunctionCall(MIN, outputColumnReferences), functionRegistry.resolveFunction(MIN, fromTypeSignatures(outputColumnTypeSignature)), Optional.empty()), maxValue, new Aggregation( new FunctionCall(MAX, outputColumnReferences), functionRegistry.resolveFunction(MAX, fromTypeSignatures(outputColumnTypeSignature)), Optional.empty()), countAllValue, new Aggregation( new FunctionCall(COUNT, emptyList()), functionRegistry.resolveFunction(COUNT, emptyList()), Optional.empty()), countNonNullValue, new Aggregation( new FunctionCall(COUNT, outputColumnReferences), functionRegistry.resolveFunction(COUNT, fromTypeSignatures(outputColumnTypeSignature)), Optional.empty())), globalAggregation(), ImmutableList.of(), AggregationNode.Step.SINGLE, Optional.empty(),
@Override public Node visitPosition(SqlBaseParser.PositionContext context) { List<Expression> arguments = Lists.reverse(visit(context.valueExpression(), Expression.class)); return new FunctionCall(getLocation(context), QualifiedName.of("strpos"), arguments); }
private static Expression getHashFunctionCall(Expression previousHashValue, Symbol symbol) { FunctionCall functionCall = new FunctionCall( QualifiedName.of(HASH_CODE), Optional.empty(), false, ImmutableList.of(symbol.toSymbolReference())); List<Expression> arguments = ImmutableList.of(previousHashValue, orNullHashCode(functionCall)); return new FunctionCall(QualifiedName.of("combine_hash"), arguments); }
Symbol symbol = entry.getKey(); if (call.getName().equals(COUNT)) { List<TypeSignature> scalarAggregationSourceTypeSignatures = ImmutableList.of( symbolAllocator.getTypes().get(nonNullableAggregationSourceSymbol).getTypeSignature()); aggregations.put(symbol, new Aggregation( new FunctionCall( COUNT, ImmutableList.of(nonNullableAggregationSourceSymbol.toSymbolReference())), functionRegistry.resolveFunction( COUNT, aggregations.build(), singleGroupingSet(leftOuterJoin.getLeft().getOutputSymbols()), ImmutableList.of(), scalarAggregation.getStep(), scalarAggregation.getHashSymbol(),
private static FunctionCall function(String functionName, Expression... args) { return new FunctionCall(QualifiedName.of(functionName), ImmutableList.copyOf(args)); }
@Override public Expression rewriteCurrentTime(CurrentTime node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { if (node.getPrecision() != null) { throw new UnsupportedOperationException("not yet implemented: non-default precision"); } switch (node.getFunction()) { case DATE: return new FunctionCall(QualifiedName.of("current_date"), ImmutableList.of()); case TIME: return new FunctionCall(QualifiedName.of("current_time"), ImmutableList.of()); case LOCALTIME: return new FunctionCall(QualifiedName.of("localtime"), ImmutableList.of()); case TIMESTAMP: return new FunctionCall(QualifiedName.of("current_timestamp"), ImmutableList.of()); case LOCALTIMESTAMP: return new FunctionCall(QualifiedName.of("localtimestamp"), ImmutableList.of()); default: throw new UnsupportedOperationException("not yet implemented: " + node.getFunction()); } }
functionCall = new FunctionCall(functionCall.getName(), functionCall.getWindow(), false, arguments.build()); aggregations.build(), singleGroupingSet(ImmutableList.copyOf(groupByKeys)), ImmutableList.of(), SINGLE, originalNode.getHashSymbol(),
private static FunctionCall function(String name, Expression... inputs) { return new FunctionCall(QualifiedName.of(name), Arrays.asList(inputs)); }
return new FunctionCall(QualifiedName.of("year"), ImmutableList.of(value)); case QUARTER: return new FunctionCall(QualifiedName.of("quarter"), ImmutableList.of(value)); case MONTH: return new FunctionCall(QualifiedName.of("month"), ImmutableList.of(value)); case WEEK: return new FunctionCall(QualifiedName.of("week"), ImmutableList.of(value)); case DAY: case DAY_OF_MONTH: return new FunctionCall(QualifiedName.of("day"), ImmutableList.of(value)); case DAY_OF_WEEK: case DOW: return new FunctionCall(QualifiedName.of("day_of_week"), ImmutableList.of(value)); case DAY_OF_YEAR: case DOY: return new FunctionCall(QualifiedName.of("day_of_year"), ImmutableList.of(value)); case YEAR_OF_WEEK: case YOW: return new FunctionCall(QualifiedName.of("year_of_week"), ImmutableList.of(value)); case HOUR: return new FunctionCall(QualifiedName.of("hour"), ImmutableList.of(value)); case MINUTE: return new FunctionCall(QualifiedName.of("minute"), ImmutableList.of(value)); case SECOND: return new FunctionCall(QualifiedName.of("second"), ImmutableList.of(value)); case TIMEZONE_MINUTE: return new FunctionCall(QualifiedName.of("timezone_minute"), ImmutableList.of(value)); case TIMEZONE_HOUR: return new FunctionCall(QualifiedName.of("timezone_hour"), ImmutableList.of(value));
new FunctionCall( call.getName(), call.getWindow(), newAggregations, parent.getGroupingSets(), ImmutableList.of(), parent.getStep(), parent.getHashSymbol(),
@Override public Node visitSubstring(SqlBaseParser.SubstringContext context) { return new FunctionCall(getLocation(context), QualifiedName.of("substr"), visit(context.valueExpression(), Expression.class)); }
private static AggregationNode.Aggregation countWithFilter(Expression condition) { FunctionCall countCall = new FunctionCall( QualifiedName.of("count"), Optional.empty(), Optional.of(condition), Optional.empty(), false, ImmutableList.<Expression>of()); /* arguments */ return new AggregationNode.Aggregation( countCall, new Signature("count", FunctionKind.AGGREGATE, BIGINT.getTypeSignature()), Optional.<Symbol>empty()); /* mask */ }
new FunctionCall(call.getName(), call.getWindow(), Optional.empty(), call.getOrderBy(), call.isDistinct(), call.getArguments()), entry.getValue().getSignature(), mask)); aggregations.build(), aggregation.getGroupingSets(), ImmutableList.of(), aggregation.getStep(), aggregation.getHashSymbol(),
private WindowNode.Function newWindowNodeFunction(String functionName, String... symbols) { return new WindowNode.Function( new FunctionCall( QualifiedName.of(functionName), Arrays.stream(symbols).map(SymbolReference::new).collect(Collectors.toList())), signature, frame); }
private AggregationNode computeCounts(UnionNode sourceNode, List<Symbol> originalColumns, List<Symbol> markers, List<Symbol> aggregationOutputs) { ImmutableMap.Builder<Symbol, Aggregation> aggregations = ImmutableMap.builder(); for (int i = 0; i < markers.size(); i++) { Symbol output = aggregationOutputs.get(i); aggregations.put(output, new Aggregation( new FunctionCall(QualifiedName.of("count"), ImmutableList.of(markers.get(i).toSymbolReference())), COUNT_AGGREGATION, Optional.empty())); } return new AggregationNode(idAllocator.getNextId(), sourceNode, aggregations.build(), singleGroupingSet(originalColumns), ImmutableList.of(), Step.SINGLE, Optional.empty(), Optional.empty()); }
@VisibleForTesting public static final class ExtractSpatialLeftJoin implements Rule<JoinNode> { private static final Pattern<JoinNode> PATTERN = join().matching(node -> node.getCriteria().isEmpty() && node.getFilter().isPresent() && node.getType() == LEFT); private final Metadata metadata; private final SplitManager splitManager; private final PageSourceManager pageSourceManager; private final SqlParser sqlParser; public ExtractSpatialLeftJoin(Metadata metadata, SplitManager splitManager, PageSourceManager pageSourceManager, SqlParser sqlParser) { this.metadata = requireNonNull(metadata, "metadata is null"); this.splitManager = requireNonNull(splitManager, "splitManager is null"); this.pageSourceManager = requireNonNull(pageSourceManager, "pageSourceManager is null"); this.sqlParser = requireNonNull(sqlParser, "sqlParser is null"); } @Override public boolean isEnabled(Session session) { return isSpatialJoinEnabled(session); } @Override public Pattern<JoinNode> getPattern() { return PATTERN; }