Search in sources :

Example 1 with JSON_STRING

use of org.apache.flink.table.functions.BuiltInFunctionDefinitions.JSON_STRING in project flink by apache.

the class WrapJsonAggFunctionArgumentsRule method addProjections.

/**
 * Adds (wrapped) projections for affected arguments of the aggregation.
 *
 * <p>Note that we cannot override any of the projections as a field may be used multiple times,
 * and in particular outside of the aggregation call. Therefore, we explicitly add the wrapped
 * projection as an additional one.
 */
private void addProjections(RelOptCluster cluster, RelBuilder relBuilder, List<Integer> affectedArgs) {
    final BridgingSqlFunction operandToStringOperator = of(cluster, JSON_STRING);
    final List<RexNode> projects = new ArrayList<>();
    affectedArgs.stream().map(argIdx -> relBuilder.call(operandToStringOperator, relBuilder.field(argIdx))).forEach(projects::add);
    relBuilder.projectPlus(projects);
}
Also used : Mappings(org.apache.calcite.util.mapping.Mappings) MappingType(org.apache.calcite.util.mapping.MappingType) ArrayList(java.util.ArrayList) RexNode(org.apache.calcite.rex.RexNode) RelBuilder(org.apache.calcite.tools.RelBuilder) RelHint(org.apache.calcite.rel.hint.RelHint) FlinkHints(org.apache.flink.table.planner.hint.FlinkHints) TargetMapping(org.apache.calcite.util.mapping.Mappings.TargetMapping) RelOptCluster(org.apache.calcite.plan.RelOptCluster) SqlJsonArrayAggAggFunction(org.apache.calcite.sql.fun.SqlJsonArrayAggAggFunction) Predicate(java.util.function.Predicate) BuiltInFunctionDefinitions(org.apache.flink.table.functions.BuiltInFunctionDefinitions) RelRule(org.apache.calcite.plan.RelRule) RelNode(org.apache.calcite.rel.RelNode) Collectors(java.util.stream.Collectors) RelOptRuleCall(org.apache.calcite.plan.RelOptRuleCall) RelOptRule(org.apache.calcite.plan.RelOptRule) List(java.util.List) LogicalAggregate(org.apache.calcite.rel.logical.LogicalAggregate) BridgingSqlFunction(org.apache.flink.table.planner.functions.bridging.BridgingSqlFunction) JSON_STRING(org.apache.flink.table.functions.BuiltInFunctionDefinitions.JSON_STRING) SqlJsonObjectAggAggFunction(org.apache.calcite.sql.fun.SqlJsonObjectAggAggFunction) Internal(org.apache.flink.annotation.Internal) AggregateCall(org.apache.calcite.rel.core.AggregateCall) SqlAggFunction(org.apache.calcite.sql.SqlAggFunction) Collections(java.util.Collections) BridgingSqlFunction.of(org.apache.flink.table.planner.functions.bridging.BridgingSqlFunction.of) ArrayList(java.util.ArrayList) BridgingSqlFunction(org.apache.flink.table.planner.functions.bridging.BridgingSqlFunction) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 RelOptCluster (org.apache.calcite.plan.RelOptCluster)1 RelOptRule (org.apache.calcite.plan.RelOptRule)1 RelOptRuleCall (org.apache.calcite.plan.RelOptRuleCall)1 RelRule (org.apache.calcite.plan.RelRule)1 RelNode (org.apache.calcite.rel.RelNode)1 AggregateCall (org.apache.calcite.rel.core.AggregateCall)1 RelHint (org.apache.calcite.rel.hint.RelHint)1 LogicalAggregate (org.apache.calcite.rel.logical.LogicalAggregate)1 RexNode (org.apache.calcite.rex.RexNode)1 SqlAggFunction (org.apache.calcite.sql.SqlAggFunction)1 SqlJsonArrayAggAggFunction (org.apache.calcite.sql.fun.SqlJsonArrayAggAggFunction)1 SqlJsonObjectAggAggFunction (org.apache.calcite.sql.fun.SqlJsonObjectAggAggFunction)1 RelBuilder (org.apache.calcite.tools.RelBuilder)1 MappingType (org.apache.calcite.util.mapping.MappingType)1 Mappings (org.apache.calcite.util.mapping.Mappings)1