amrishlal commented on a change in pull request #6878: URL: https://github.com/apache/incubator-pinot/pull/6878#discussion_r627773862
########## File path: pinot-common/src/main/java/org/apache/pinot/common/utils/PinotDataType.java ########## @@ -538,6 +600,58 @@ public String convert(Object value, PinotDataType sourceType) { } }, + JSON { + @Override + public int toInt(Object value) { + throw new UnsupportedOperationException("Cannot convert value from JSON to INT"); + } + + @Override + public long toLong(Object value) { + throw new UnsupportedOperationException("Cannot convert value from JSON to LONG"); + } + + @Override + public float toFloat(Object value) { + throw new UnsupportedOperationException("Cannot convert value from JSON to FLOAT"); + } + + @Override + public double toDouble(Object value) { + throw new UnsupportedOperationException("Cannot convert value from JSON to DOUBLE"); + } + + @Override + public boolean toBoolean(Object value) { + throw new UnsupportedOperationException("Cannot convert value from JSON to BOOLEAN"); + } + + @Override + public Timestamp toTimestamp(Object value) { + throw new UnsupportedOperationException("Cannot convert value from JSON to TIMESTAMP"); + } + + @Override + public String toString(Object value) { + return value.toString(); + } + + @Override + public String toJson(Object value) { + return value.toString(); + } + + @Override + public byte[] toBytes(Object value) { + throw new UnsupportedOperationException("Cannot convert value from JSON to BYTES"); + } + + @Override + public String convert(Object value, PinotDataType sourceType) { + return sourceType.toString(value); Review comment: Fixed. ########## File path: pinot-common/src/main/java/org/apache/pinot/common/utils/PinotDataType.java ########## @@ -538,6 +600,58 @@ public String convert(Object value, PinotDataType sourceType) { } }, + JSON { + @Override + public int toInt(Object value) { Review comment: Fixed. ########## File path: pinot-common/src/main/java/org/apache/pinot/common/utils/PinotDataType.java ########## @@ -748,6 +874,20 @@ public String toString(Object value) { return getSingleValueType().toString(toObjectArray(value)[0]); } + public String toJson(Object value) { + String jsonString = getSingleValueType().toString(toObjectArray(value)[0]); + + // Check if the string is valid JSON. + JsonNode jsonNode = null; + try { + jsonNode = JsonUtils.stringToJsonNode(jsonString); + } catch (IOException ioe) { + throw new UnsupportedOperationException("Cannot convert value from STRING to JSON"); + } + + return jsonNode.toString(); + } Review comment: Fixed. ########## File path: pinot-common/src/main/java/org/apache/pinot/common/utils/PinotDataType.java ########## @@ -986,7 +1126,7 @@ public PinotDataType getSingleValueType() { /** * Returns the {@link PinotDataType} for the given {@link FieldSpec} for data ingestion purpose. Returns object array * type for multi-valued types. - * TODO: Add MV support for BOOLEAN, TIMESTAMP, BYTES + * TODO: Add MV support for BOOLEAN, TIMESTAMP, BYTES, JSON 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 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org