harshmotw-db commented on code in PR #47473: URL: https://github.com/apache/spark/pull/47473#discussion_r1690393525
########## common/variant/src/main/java/org/apache/spark/types/variant/Variant.java: ########## @@ -316,6 +334,22 @@ static void toJsonImpl(byte[] value, byte[] metadata, int pos, StringBuilder sb, case BINARY: appendQuoted(sb, Base64.getEncoder().encodeToString(VariantUtil.getBinary(value, pos))); break; + case YEAR_MONTH_INTERVAL: + IntervalFields ymFields = VariantUtil.getYearMonthIntervalFields(value, pos); + int ymValue = (int) VariantUtil.getLong(value, pos); + appendQuoted(sb, YearMonthIntervalUtils + .toYearMonthIntervalANSIString(ymValue, ymFields.startField, ymFields.endField)); + break; + case DAY_TIME_INTERVAL: + IntervalFields dtFields = VariantUtil.getDayTimeIntervalFields(value, pos); + long dtValue = VariantUtil.getLong(value, pos); + try { Review Comment: It can throw an exception when the field ranges are out of bounds. That being said, `getDayTimeIntervalFields` ensures that they are always within bounds the try block is unnecessary. Thanks! -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org