private static DruidExpression toDruidExpressionForSimpleAggregator( final PlannerContext plannerContext, final RowSignature rowSignature, final RexNode rexNode ) { final DruidExpression druidExpression = Expressions.toDruidExpression(plannerContext, rowSignature, rexNode); if (druidExpression == null) { return null; } if (druidExpression.isSimpleExtraction() && (!druidExpression.isDirectColumnAccess() || rowSignature.getColumnType(druidExpression.getDirectColumn()) == ValueType.STRING)) { // Aggregators are unable to implicitly cast strings to numbers. So remove the simple extraction in this case. return druidExpression.map(simpleExtraction -> null, Function.identity()); } else { return druidExpression; } } }
if (expression.isDirectColumnAccess()) { directColumns.add(expression.getDirectColumn()); rowOrder.add(expression.getDirectColumn());
final String expression; if (arg.isDirectColumnAccess()) { fieldName = arg.getDirectColumn(); expression = null;
final String expression; if (arg.isDirectColumnAccess()) { fieldName = arg.getDirectColumn(); expression = null;
final String expression; if (arg.isDirectColumnAccess()) { fieldName = arg.getDirectColumn(); expression = null;
final String expression; if (arg.isDirectColumnAccess()) { fieldName = arg.getDirectColumn(); expression = null;
inputMatches = input.isDirectColumnAccess() && input.getDirectColumn().equals(theFactory.getFieldName()); } else { if (input.isDirectColumnAccess()) { if (rowSignature.getColumnType(input.getDirectColumn()) == ValueType.COMPLEX) { aggregatorFactory = new ApproximateHistogramFoldingAggregatorFactory(
/** * Returns true if a post-aggregation "expression" can be realized as a direct field access. This is true if it's * a direct column access that doesn't require an implicit cast. * * @param aggregateRowSignature signature of the aggregation * @param expression post-aggregation expression * @param rexNode RexNode for the post-aggregation expression * * @return yes or no */ private static boolean postAggregatorDirectColumnIsOk( final RowSignature aggregateRowSignature, final DruidExpression expression, final RexNode rexNode ) { if (!expression.isDirectColumnAccess()) { return false; } // Check if a cast is necessary. final ExprType toExprType = Expressions.exprTypeForValueType( aggregateRowSignature.getColumnType(expression.getDirectColumn()) ); final ExprType fromExprType = Expressions.exprTypeForValueType( Calcites.getValueTypeForSqlTypeName(rexNode.getType().getSqlTypeName()) ); return toExprType.equals(fromExprType); }
final String aggregatorName = finalizeAggregations ? Calcites.makePrefixedName(name, "a") : name; if (arg.isDirectColumnAccess() && rowSignature.getColumnType(arg.getDirectColumn()) == ValueType.COMPLEX) { aggregatorFactory = new HyperUniquesAggregatorFactory(aggregatorName, arg.getDirectColumn(), false, true); } else {
private static DruidExpression toDruidExpressionForSimpleAggregator( final PlannerContext plannerContext, final RowSignature rowSignature, final RexNode rexNode ) { final DruidExpression druidExpression = Expressions.toDruidExpression(plannerContext, rowSignature, rexNode); if (druidExpression == null) { return null; } if (druidExpression.isSimpleExtraction() && (!druidExpression.isDirectColumnAccess() || rowSignature.getColumnType(druidExpression.getDirectColumn()) == ValueType.STRING)) { // Aggregators are unable to implicitly cast strings to numbers. So remove the simple extraction in this case. return druidExpression.map(simpleExtraction -> null, Function.identity()); } else { return druidExpression; } } }
if (expression.isDirectColumnAccess()) { directColumns.add(expression.getDirectColumn()); rowOrder.add(expression.getDirectColumn());
final String expression; if (arg.isDirectColumnAccess()) { fieldName = arg.getDirectColumn(); expression = null;
final String expression; if (arg.isDirectColumnAccess()) { fieldName = arg.getDirectColumn(); expression = null;
final String expression; if (arg.isDirectColumnAccess()) { fieldName = arg.getDirectColumn(); expression = null;
inputMatches = input.isDirectColumnAccess() && input.getDirectColumn().equals(theFactory.getFieldName()); } else { if (input.isDirectColumnAccess()) { if (rowSignature.getColumnType(input.getDirectColumn()) == ValueType.COMPLEX) { aggregatorFactory = new ApproximateHistogramFoldingAggregatorFactory(
final String expression; if (arg.isDirectColumnAccess()) { fieldName = arg.getDirectColumn(); expression = null;
/** * Returns true if a post-aggregation "expression" can be realized as a direct field access. This is true if it's * a direct column access that doesn't require an implicit cast. * * @param aggregateRowSignature signature of the aggregation * @param expression post-aggregation expression * @param rexNode RexNode for the post-aggregation expression * * @return yes or no */ private static boolean postAggregatorDirectColumnIsOk( final RowSignature aggregateRowSignature, final DruidExpression expression, final RexNode rexNode ) { if (!expression.isDirectColumnAccess()) { return false; } // Check if a cast is necessary. final ExprType toExprType = Expressions.exprTypeForValueType( aggregateRowSignature.getColumnType(expression.getDirectColumn()) ); final ExprType fromExprType = Expressions.exprTypeForValueType( Calcites.getValueTypeForSqlTypeName(rexNode.getType().getSqlTypeName()) ); return toExprType.equals(fromExprType); }
final String aggregatorName = finalizeAggregations ? Calcites.makePrefixedName(name, "a") : name; if (arg.isDirectColumnAccess() && rowSignature.getColumnType(arg.getDirectColumn()) == ValueType.COMPLEX) { aggregatorFactory = new HyperUniquesAggregatorFactory(aggregatorName, arg.getDirectColumn(), false, true); } else {