ShivamSharma43 opened a new pull request, #1656: URL: https://github.com/apache/arrow-go/pull/1656
### Rationale for this change Writing a dictionary array with temporal values to Parquet can store wrong values without any error. `writeDictionaryArrow` passes the dictionary of any primitive value type straight to the encoder, so the conversions that `writeDenseArrow` does for the same type are skipped, while the column's logical type still says they happened. With the default writer properties, `dictionary<timestamp[s]>` and `dictionary<time32[s]>` are written as raw seconds into a column declared as milliseconds: ``` written: 2020-01-01T01:02:03Z read back: 1970-01-19T06:17:20.523Z ``` The same happens for - `dictionary<timestamp[ns]>` in version 1.0 and 2.4 files, where the column is declared as microseconds - any `dictionary<timestamp>` whose unit is changed by `WithCoerceTimestamps` Two more value types need a conversion and fail to write at all: `date64` (`function 'cast_int32' has no kernel matching input types (date64)`) and `float16` (`only fixed size binary and decimal128 arrays are supported`). The same arrays are written correctly when dictionary encoding is disabled for the column. Arrow C++ only takes the direct path for binary-like values (`DictionaryDirectWriteSupported`), so it isn't affected. ### What changes are included in this PR? `dictionaryDirectWriteSupported` returns false for the value types that Parquet stores in a different representation, so these arrays are decoded and go through `writeDenseArrow`. The column is still dictionary encoded, since the dense writer builds its own dictionary. For timestamps it compares the unit of the values with the unit in the column's logical type, so timestamps that need no conversion keep using the direct path. ### Are these changes tested? Yes, `TestWriteDictionaryConvertsValues` writes a sliced dictionary array with a null for each of these types, plus the types that don't need a conversion, and checks the values read back. Without the fix, 8 of its 16 cases fail: 6 read back wrong values and 2 fail to write. On Windows amd64 with Go 1.26.9, `go test -tags assert ./parquet/pqarrow/... ./parquet/internal/encoding/...`, `go test -tags assert,noasm ./parquet/pqarrow/...` and `go vet ./parquet/pqarrow` pass. ### Are there any user-facing changes? Dictionary arrays with these value types are now written with the right values, and `date64` and `float16` dictionaries can be written. No API changes. Files that were already written with the wrong values are not affected by this change. This PR was prepared with AI assistance (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
