Repository navigation
GH-47189: [C++][Parquet] Fix ParquetFilePrinter to produce valid JSON statistics - #47190
Conversation
|
|
|
Current output: Before: |
|
cc @raulcd This might affect your changes on stats. |
…d JSON for statistics
| std::memcpy(&value, bytes, sizeof(bool)); | ||
| result << value; | ||
| break; | ||
| return FormatNumericValue<bool>(val); |
There was a problem hiding this comment.
There was a problem hiding this comment.
What about an extra << boolalpha ? I think using numeric here is too C-style...
There was a problem hiding this comment.
That makes sense. Let me revert this.
| if (logical_type != nullptr && logical_type->is_decimal()) { | ||
| return FormatDecimalValue(parquet_type, val, logical_type); | ||
| } |
There was a problem hiding this comment.
Good catch! I forgot to clean up these duplicate lines.
| const std::shared_ptr<const LogicalType>& logical_type) { | ||
| ARROW_DCHECK(logical_type != nullptr && logical_type->is_decimal()); |
There was a problem hiding this comment.
Can pass in argument just be const DecimalLogicalType&? ( Current also LGTM)
There was a problem hiding this comment.
Then the caller needs to check nullability.
| } | ||
| if (logical_type->is_string()) { | ||
| return std::string(val); | ||
| } |
There was a problem hiding this comment.
Added. I think we are still missing format functions for other logical types like timestamp, geometry, etc. We can add them as needed.
mapleFU
left a comment
There was a problem hiding this comment.
This is a good begining for prining specific values!
|
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 19f3b85. There weren't enough matching historic benchmark results to make a call on whether there were regressions. The full Conbench report has more details. |
Rationale for this change
ParquetFilePrinter uses FormatStatValue to print min/max stats. If stats contain non-UTF8 data, produced JSON is invalid.
What changes are included in this PR?
Make FormatStatValue aware of logical type and print hex values for binary data.
Are these changes tested?
Added test case to validate json output.
Are there any user-facing changes?
Yes, users may see hex values for binary values instead of char values in the past.