xiangfu0 commented on code in PR #13905:
URL: https://github.com/apache/pinot/pull/13905#discussion_r1735203149


##########
pinot-spi/src/main/java/org/apache/pinot/spi/data/ComplexFieldSpec.java:
##########
@@ -87,6 +98,58 @@ public FieldType getFieldType() {
 
   @Override
   public String toString() {
-    return "field type: COMPLEX, field name: " + _name + ", root data type: " 
+ _dataType;
+    return "field type: COMPLEX, field name: " + _name + ", root data type: " 
+ _dataType + ", child field specs: "
+        + _childFieldSpecs;
+  }
+
+  public static class MapFieldSpec {
+    private final String _fieldName;
+    private final FieldSpec _keyFieldSpec;
+    private final FieldSpec _valueFieldSpec;
+
+    private MapFieldSpec(ComplexFieldSpec complexFieldSpec) {
+      
Preconditions.checkState(complexFieldSpec.getChildFieldSpecs().containsKey(KEY_FIELD),
+          "Missing 'key' in the 'childFieldSpec'");
+      
Preconditions.checkState(complexFieldSpec.getChildFieldSpecs().containsKey(VALUE_FIELD),
+          "Missing 'value' in the 'childFieldSpec'");
+      _keyFieldSpec = complexFieldSpec.getChildFieldSpec(KEY_FIELD);
+      _valueFieldSpec = complexFieldSpec.getChildFieldSpec(VALUE_FIELD);
+      _fieldName = complexFieldSpec.getName();
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
+
+    public FieldSpec getKeyFieldSpec() {
+      return _keyFieldSpec;
+    }
+
+    public FieldSpec getValueFieldSpec() {
+      return _valueFieldSpec;
+    }
+  }
+
+  public static MapFieldSpec fromMapFieldSpec(ComplexFieldSpec 
complexFieldSpec) {
+    return new MapFieldSpec(complexFieldSpec);
+  }
+
+  public static ComplexFieldSpec fromMapFieldSpec(MapFieldSpec mapFieldSpec) {
+    return new ComplexFieldSpec(mapFieldSpec.getFieldName(), DataType.MAP, 
true,
+        Map.of(KEY_FIELD, mapFieldSpec.getKeyFieldSpec(), VALUE_FIELD, 
mapFieldSpec.getValueFieldSpec()));
+  }
+
+  public static String getFullChildName(String... columns) {

Review Comment:
   Added a few. It's used for column metadata persistence.



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to