ihuzenko commented on a change in pull request #1374: [CALCITE-3138] 
Restructuring ROW type fields is not supported
URL: https://github.com/apache/calcite/pull/1374#discussion_r314292978
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/sql2rel/RelStructuredTypeFlattener.java
 ##########
 @@ -581,68 +555,52 @@ public void rewriteGeneric(RelNode rel) {
   }
 
   private void flattenProjections(RewriteRexShuttle shuttle,
-      List<? extends RexNode> exps,
-      List<String> fieldNames,
-      String prefix,
-      List<Pair<RexNode, String>> flattenedExps) {
+                                  List<? extends RexNode> exps,
+                                  List<String> fieldNames,
+                                  String prefix,
+                                  List<Pair<RexNode, String>> flattenedExps) {
     for (int i = 0; i < exps.size(); ++i) {
       RexNode exp = exps.get(i);
-      String fieldName =
-          (fieldNames == null || fieldNames.get(i) == null)
-              ? ("$" + i)
-              : fieldNames.get(i);
-      if (!prefix.equals("")) {
-        fieldName = prefix + "$" + fieldName;
-      }
+      String fieldName = extractName(fieldNames, prefix, i);
       flattenProjection(shuttle, exp, fieldName, flattenedExps);
     }
   }
 
+  private String extractName(List<String> fieldNames, String prefix, int i) {
+    String fieldName = (fieldNames == null || fieldNames.get(i) == null)
+        ? ("$" + i)
+        : fieldNames.get(i);
+    if (!prefix.equals("")) {
+      fieldName = prefix + "$" + fieldName;
+    }
+    return fieldName;
+  }
+
   private void flattenProjection(RewriteRexShuttle shuttle,
-      RexNode exp,
-      String fieldName,
-      List<Pair<RexNode, String>> flattenedExps) {
+                                 RexNode exp,
 
 Review comment:
   Fixed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to