public Type getTypeForSymbol(Symbol symbol) { return types.get(symbol); } }
private Type checkedTypeLookup(Symbol symbol) { Type type = types.get(symbol); checkArgument(type != null, "Types is missing info for symbol: %s", symbol); return type; }
private Type checkedTypeLookup(Symbol symbol) { Type type = types.get(symbol); checkArgument(type != null, "Types is missing info for symbol: %s", symbol); return type; }
private boolean canSkipHashGeneration(List<Symbol> partitionSymbols) { // HACK: bigint grouped aggregation has special operators that do not use precomputed hash, so we can skip hash generation return partitionSymbols.isEmpty() || (partitionSymbols.size() == 1 && types.get(Iterables.getOnlyElement(partitionSymbols)).equals(BIGINT)); }
private boolean canSkipHashGeneration(List<Symbol> partitionSymbols) { // HACK: bigint grouped aggregation has special operators that do not use precomputed hash, so we can skip hash generation return partitionSymbols.isEmpty() || (partitionSymbols.size() == 1 && types.get(Iterables.getOnlyElement(partitionSymbols)).equals(BIGINT)); }
/** * Returns estimated data size. * Unknown value is represented by {@link Double#NaN} */ public double getOutputSizeInBytes(Collection<Symbol> outputSymbols, TypeProvider types) { requireNonNull(outputSymbols, "outputSymbols is null"); return outputSymbols.stream() .mapToDouble(symbol -> getOutputSizeForSymbol(getSymbolStatistics(symbol), types.get(symbol))) .sum(); }
/** * Returns estimated data size. * Unknown value is represented by {@link Double#NaN} */ public double getOutputSizeInBytes(Collection<Symbol> outputSymbols, TypeProvider types) { requireNonNull(outputSymbols, "outputSymbols is null"); return outputSymbols.stream() .mapToDouble(symbol -> getOutputSizeForSymbol(getSymbolStatistics(symbol), types.get(symbol))) .sum(); }
private NumericValues(Symbol column, T min, T integerNegative, T fractionalNegative, T integerPositive, T fractionalPositive, T max) { this.column = requireNonNull(column, "column is null"); this.type = requireNonNull(TYPES.get(column), "type for column not found: " + column); this.min = requireNonNull(min, "min is null"); this.integerNegative = requireNonNull(integerNegative, "integerNegative is null"); this.fractionalNegative = requireNonNull(fractionalNegative, "fractionalNegative is null"); this.integerPositive = requireNonNull(integerPositive, "integerPositive is null"); this.fractionalPositive = requireNonNull(fractionalPositive, "fractionalPositive is null"); this.max = requireNonNull(max, "max is null"); }
private NumericValues(Symbol column, T min, T integerNegative, T fractionalNegative, T integerPositive, T fractionalPositive, T max) { this.column = requireNonNull(column, "column is null"); this.type = requireNonNull(TYPES.get(column), "type for column not found: " + column); this.min = requireNonNull(min, "min is null"); this.integerNegative = requireNonNull(integerNegative, "integerNegative is null"); this.fractionalNegative = requireNonNull(fractionalNegative, "fractionalNegative is null"); this.integerPositive = requireNonNull(integerPositive, "integerPositive is null"); this.fractionalPositive = requireNonNull(fractionalPositive, "fractionalPositive is null"); this.max = requireNonNull(max, "max is null"); }
@Override public Optional<PlanNodeStatsEstimate> calculate(ValuesNode node, StatsProvider sourceStats, Lookup lookup, Session session, TypeProvider types) { PlanNodeStatsEstimate.Builder statsBuilder = PlanNodeStatsEstimate.builder(); statsBuilder.setOutputRowCount(node.getRows().size()); for (int symbolId = 0; symbolId < node.getOutputSymbols().size(); ++symbolId) { Symbol symbol = node.getOutputSymbols().get(symbolId); List<Object> symbolValues = getSymbolValues(node, symbolId, session, types.get(symbol)); statsBuilder.addSymbolStatistics(symbol, buildSymbolStatistics(symbolValues, session, types.get(symbol))); } return Optional.of(statsBuilder.build()); }
@Override public Optional<PlanNodeStatsEstimate> calculate(ValuesNode node, StatsProvider sourceStats, Lookup lookup, Session session, TypeProvider types) { PlanNodeStatsEstimate.Builder statsBuilder = PlanNodeStatsEstimate.builder(); statsBuilder.setOutputRowCount(node.getRows().size()); for (int symbolId = 0; symbolId < node.getOutputSymbols().size(); ++symbolId) { Symbol symbol = node.getOutputSymbols().get(symbolId); List<Object> symbolValues = getSymbolValues(node, symbolId, session, types.get(symbol)); statsBuilder.addSymbolStatistics(symbol, buildSymbolStatistics(symbolValues, session, types.get(symbol))); } return Optional.of(statsBuilder.build()); }
private void checkSignature(Symbol symbol, Signature signature) { TypeSignature expectedTypeSignature = types.get(symbol).getTypeSignature(); TypeSignature actualTypeSignature = signature.getReturnType(); verifyTypeSignature(symbol, expectedTypeSignature, actualTypeSignature); }
private void checkCall(Symbol symbol, FunctionCall call) { Type expectedType = types.get(symbol); Map<NodeRef<Expression>, Type> expressionTypes = getExpressionTypes(session, metadata, sqlParser, types, call, emptyList(), warningCollector); Type actualType = expressionTypes.get(NodeRef.<Expression>of(call)); verifyTypeSignature(symbol, expectedType.getTypeSignature(), actualType.getTypeSignature()); }
private void checkCall(Symbol symbol, FunctionCall call) { Type expectedType = types.get(symbol); Map<NodeRef<Expression>, Type> expressionTypes = getExpressionTypes(session, metadata, sqlParser, types, call, emptyList(), warningCollector); Type actualType = expressionTypes.get(NodeRef.<Expression>of(call)); verifyTypeSignature(symbol, expectedType.getTypeSignature(), actualType.getTypeSignature()); }
private void checkSignature(Symbol symbol, Signature signature) { TypeSignature expectedTypeSignature = types.get(symbol).getTypeSignature(); TypeSignature actualTypeSignature = signature.getReturnType(); verifyTypeSignature(symbol, expectedTypeSignature, actualTypeSignature); }
private boolean checkAllEquatableTypes(AggregateInfo aggregateInfo) { for (Symbol symbol : aggregateInfo.getOriginalNonDistinctAggregateArgs()) { Type type = symbolAllocator.getTypes().get(symbol); if (!type.isComparable()) { return false; } } if (!symbolAllocator.getTypes().get(aggregateInfo.getMask()).isComparable()) { return false; } return true; }
private Signature getFunctionSignature(QualifiedName functionName, Symbol argument) { return metadata.getFunctionRegistry() .resolveFunction( functionName, ImmutableList.of(new TypeSignatureProvider(symbolAllocator.getTypes().get(argument).getTypeSignature()))); }
private Signature getFunctionSignature(QualifiedName functionName, Symbol argument) { return metadata.getFunctionRegistry() .resolveFunction( functionName, ImmutableList.of(new TypeSignatureProvider(symbolAllocator.getTypes().get(argument).getTypeSignature()))); }
@Override protected Type visitSymbolReference(SymbolReference node, StackableAstVisitorContext<Context> context) { if (context.getContext().isInLambda()) { Optional<ResolvedField> resolvedField = context.getContext().getScope().tryResolveField(node, QualifiedName.of(node.getName())); if (resolvedField.isPresent() && context.getContext().getFieldToLambdaArgumentDeclaration().containsKey(FieldId.from(resolvedField.get()))) { return setExpressionType(node, resolvedField.get().getType()); } } Type type = symbolTypes.get(Symbol.from(node)); return setExpressionType(node, type); }
@Override protected Type visitSymbolReference(SymbolReference node, StackableAstVisitorContext<Context> context) { if (context.getContext().isInLambda()) { Optional<ResolvedField> resolvedField = context.getContext().getScope().tryResolveField(node, QualifiedName.of(node.getName())); if (resolvedField.isPresent() && context.getContext().getFieldToLambdaArgumentDeclaration().containsKey(FieldId.from(resolvedField.get()))) { return setExpressionType(node, resolvedField.get().getType()); } } Type type = symbolTypes.get(Symbol.from(node)); return setExpressionType(node, type); }