Vamsi-klu commented on code in PR #18976:
URL: https://github.com/apache/pinot/pull/18976#discussion_r4647652258
##########
pinot-plugins/pinot-input-format/pinot-json/src/main/java/org/apache/pinot/plugin/inputformat/json/JSONRecordReader.java:
##########
@@ -49,7 +49,7 @@ private void init()
throws IOException {
_inputStream = RecordReaderUtils.getBufferedInputStream(_dataFile);
try {
- _iterator = JsonUtils.DEFAULT_READER.forType(new
TypeReference<Map<String, Object>>() {
+ _iterator = JsonUtils.READER_WITH_BIG_DECIMAL.forType(new
TypeReference<Map<String, Object>>() {
}).readValues(_inputStream);
Review Comment:
**Local validation update.** The repair and tests described below are staged
locally. The published PR head is `5501bb3844`.
I reproduced the cast failure on the reviewed head. The converter now uses
each element's numeric type when the inferred array source is numeric, so both
element orders work. Decimals retain their precision and integral values
convert without a double round trip. A numeric string after a JSON decimal
still parses as it did before the decoder change. The regression builds and
reopens both dictionary and raw segments from JSON, then checks the actual
values. I also exercised the streaming decoder through schema conversion.
Drafted-by: OpenAI Codex (GPT-6); reviewed by @Vamsi-klu before posting
##########
pinot-plugins/pinot-input-format/pinot-json/src/main/java/org/apache/pinot/plugin/inputformat/json/format/JacksonPayloadParser.java:
##########
@@ -109,17 +115,24 @@ public boolean parse(byte[] payload, int offset, int
length, GenericRow destinat
/// Materializes the value at the parser's current token in
[JSONRecordExtractor]'s converted shape. Scalars
/// are read straight off the parser rather than through databind, which
allocates a fresh
/// `DeserializationContext` per `readValue` call. `getNumberValue()` keeps
the binary formats' `Float`
- /// (never upcast to `Double`) and text JSON's `Double`, matching Jackson's
untyped materialization.
+ /// (never upcast to `Double`). Text-backed formats use `getDecimalValue()`
for floats so decimal literals
+ /// are not rounded to `Double` before Pinot's schema conversion.
@Nullable
private Object readValue(JsonParser parser, JsonToken valueToken)
throws IOException {
switch (valueToken) {
case VALUE_STRING:
return parser.getText();
case VALUE_NUMBER_INT:
- case VALUE_NUMBER_FLOAT:
// Oversized ints widen to BigDecimal via the shared contract (Pinot
has no BigInteger type)
return JSONRecordExtractor.convert(parser.getNumberValue());
+ case VALUE_NUMBER_FLOAT:
+ // JSON text stores decimals as decimal *text*. Jackson's default
getNumberValue() rounds that text
+ // to Double. Avro and Protobuf extractors do not have this problem:
they carry typed numeric
+ // values (Avro's decimal logical type is already BigDecimal). Binary
JSON formats encode IEEE
+ // floats natively, so they keep getNumberValue().
+ return JSONRecordExtractor.convert(
+ _preserveDecimalFloats ? parser.getDecimalValue() :
parser.getNumberValue());
Review Comment:
**Local validation update.** The repair and tests described below are staged
locally. The published PR head is `5501bb3844`.
The existing fix compares decimal zero by numeric value. The
decoder-to-schema test covers `0.0`, `-0.0` and `0E+3`, all stored as false by
the transformer.
Drafted-by: OpenAI Codex (GPT-6); reviewed by @Vamsi-klu before posting
##########
pinot-plugins/pinot-input-format/pinot-json/src/main/java/org/apache/pinot/plugin/inputformat/json/JSONRecordReader.java:
##########
@@ -49,7 +49,7 @@ private void init()
throws IOException {
_inputStream = RecordReaderUtils.getBufferedInputStream(_dataFile);
try {
- _iterator = JsonUtils.DEFAULT_READER.forType(new
TypeReference<Map<String, Object>>() {
+ _iterator = JsonUtils.READER_WITH_BIG_DECIMAL.forType(new
TypeReference<Map<String, Object>>() {
}).readValues(_inputStream);
Review Comment:
**Local validation update.** The repair and tests described below are staged
locally. The published PR head is `5501bb3844`.
The existing per-element STRING conversion is still covered. The
decoder-to-schema test checks that an integer followed by `1E+7` becomes
`["2","10000000"]`.
Drafted-by: OpenAI Codex (GPT-6); reviewed by @Vamsi-klu before posting
##########
pinot-plugins/pinot-input-format/pinot-json/src/main/java/org/apache/pinot/plugin/inputformat/json/format/TextJsonPayloadParser.java:
##########
@@ -22,11 +22,12 @@
/// Parses UTF-8 text JSON, the historical
[org.apache.pinot.plugin.inputformat.json.JSONMessageDecoder]
-/// behavior. Uses the same Jackson map/value materialization contract as the
binary JSON parsers.
+/// format. Floating literals are `BigDecimal` so high-precision decimals
survive ingestion; this is
+/// always on because it is the correct behavior for decimal text, not an
opt-in.
class TextJsonPayloadParser extends JacksonPayloadParser {
TextJsonPayloadParser() {
- super(JsonUtils.DEFAULT_READER);
+ super(JsonUtils.READER_WITH_BIG_DECIMAL);
Review Comment:
**Local validation update.** The repair and tests described below are staged
locally. The published PR head is `5501bb3844`.
The existing `nullIf` fix compares the numeric values. The
ingestion-expression tests cover a BigDecimal against the Double literal and a
decimal against an equal value with a different scale.
Drafted-by: OpenAI Codex (GPT-6); reviewed by @Vamsi-klu before posting
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]