Skip to content

Commit a93660b

Browse files
Address coderrabbit comments
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
1 parent 6510d2b commit a93660b

1 file changed

Lines changed: 0 additions & 116 deletions

File tree

core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -3118,122 +3118,6 @@ public RelNode visitExpand(Expand expand, CalcitePlanContext context) {
31183118
return context.relBuilder.peek();
31193119
}
31203120

3121-
// /**
3122-
// * mvcombine command visitor to collapse rows that are identical on all fields except the
3123-
// target
3124-
// * field, and combine the target field values into a multivalue (array) field.
3125-
// *
3126-
// *
3127-
// * @param node mvcombine command to be visited
3128-
// * @param context CalcitePlanContext containing the RelBuilder, RexBuilder, and resolution
3129-
// context
3130-
// * @return RelNode representing records collapsed by all non-target fields with the target
3131-
// field
3132-
// * combined into a multivalue array (or a delimited string when {@code nomv=true})
3133-
// */
3134-
// @Override
3135-
// public RelNode visitMvCombine(MvCombine node, CalcitePlanContext context) {
3136-
// // 1) Lower child first
3137-
// visitChildren(node, context);
3138-
//
3139-
// final RelBuilder relBuilder = context.relBuilder;
3140-
// final RexBuilder rexBuilder = context.rexBuilder;
3141-
//
3142-
// final RelNode input = relBuilder.peek();
3143-
// final List<String> inputFieldNames = input.getRowType().getFieldNames();
3144-
//
3145-
// // 2) Accept delim (default is single space).
3146-
// // NOTE: delim only affects single-value rendering when nomv=true.
3147-
// final String delim = node.getDelim();
3148-
//
3149-
// // 3) Resolve target field to an input ref (must be a direct field reference)
3150-
// final Field targetField = node.getField();
3151-
// final RexNode targetRex = rexVisitor.analyze(targetField, context);
3152-
// if (!(targetRex instanceof RexInputRef)) {
3153-
// throw new SemanticCheckException(
3154-
// "mvcombine target must be a direct field reference, but got: " + targetField);
3155-
// }
3156-
// final int targetIndex = ((RexInputRef) targetRex).getIndex();
3157-
// final String targetName = inputFieldNames.get(targetIndex);
3158-
//
3159-
// // 4) Group key = all fields except target
3160-
// final List<RexNode> groupExprs = new ArrayList<>();
3161-
// for (int i = 0; i < inputFieldNames.size(); i++) {
3162-
// if (i == targetIndex) continue;
3163-
// groupExprs.add(relBuilder.field(i));
3164-
// }
3165-
//
3166-
// // 5) Aggregate target values: COLLECT => MULTISET
3167-
// final RelBuilder.AggCall aggCall =
3168-
// relBuilder
3169-
// .aggregateCall(SqlStdOperatorTable.COLLECT, relBuilder.field(targetIndex))
3170-
// .as(targetName);
3171-
//
3172-
// relBuilder.aggregate(relBuilder.groupKey(groupExprs), aggCall);
3173-
//
3174-
// // 6) Restore original output column order AND cast MULTISET -> ARRAY using RexBuilder
3175-
// // After aggregate => [group fields..., targetAgg(multiset)]
3176-
// final int aggPos = groupExprs.size();
3177-
//
3178-
// final RelDataType elemType = input.getRowType().getFieldList().get(targetIndex).getType();
3179-
// final RelDataType arrayType = relBuilder.getTypeFactory().createArrayType(elemType, -1);
3180-
//
3181-
// final List<RexNode> projections = new ArrayList<>(inputFieldNames.size());
3182-
// final List<String> projNames = new ArrayList<>(inputFieldNames.size());
3183-
//
3184-
// int groupPos = 0;
3185-
// for (int i = 0; i < inputFieldNames.size(); i++) {
3186-
// projNames.add(inputFieldNames.get(i));
3187-
// if (i == targetIndex) {
3188-
// final RexNode multisetRef = relBuilder.field(aggPos); // MULTISET
3189-
// projections.add(rexBuilder.makeCast(arrayType, multisetRef)); // ARRAY
3190-
// } else {
3191-
// projections.add(relBuilder.field(groupPos));
3192-
// groupPos++;
3193-
// }
3194-
// }
3195-
// relBuilder.project(projections, projNames, /* force= */ true);
3196-
//
3197-
// // 7) nomv=true converts multivalue output to a single delimited string.
3198-
// // arrayToString in this engine supports only String/ByteString, so cast elements to STRING
3199-
// // first.
3200-
// if (node.isNomv()) {
3201-
// final List<RexNode> nomvProjections = new ArrayList<>(inputFieldNames.size());
3202-
// final List<String> nomvNames = new ArrayList<>(inputFieldNames.size());
3203-
//
3204-
// // Build ARRAY<VARCHAR> type once
3205-
// final RelDataType stringType =
3206-
// relBuilder
3207-
// .getTypeFactory()
3208-
// .createSqlType(org.apache.calcite.sql.type.SqlTypeName.VARCHAR);
3209-
// final RelDataType stringArrayType =
3210-
// relBuilder.getTypeFactory().createArrayType(stringType, -1);
3211-
//
3212-
// for (int i = 0; i < inputFieldNames.size(); i++) {
3213-
// final String name = inputFieldNames.get(i);
3214-
// nomvNames.add(name);
3215-
//
3216-
// if (i == targetIndex) {
3217-
// // At this point relBuilder.field(i) is ARRAY<elemType>. Cast to ARRAY<VARCHAR> so
3218-
// // ARRAY_TO_STRING works.
3219-
// final RexNode stringArray = rexBuilder.makeCast(stringArrayType, relBuilder.field(i));
3220-
//
3221-
// nomvProjections.add(
3222-
// relBuilder.call(
3223-
// org.apache.calcite.sql.fun.SqlLibraryOperators.ARRAY_TO_STRING,
3224-
// stringArray,
3225-
// relBuilder.literal(delim)));
3226-
// } else {
3227-
// nomvProjections.add(relBuilder.field(i));
3228-
// }
3229-
// }
3230-
//
3231-
// relBuilder.project(nomvProjections, nomvNames, /* force= */ true);
3232-
// }
3233-
//
3234-
// return relBuilder.peek();
3235-
// }
3236-
32373121
/**
32383122
* mvcombine command visitor to collapse rows that are identical on all fields except the target
32393123
* field, and combine the target field values into a multivalue (array) field.

0 commit comments

Comments
 (0)