Uh oh!
There was an error while loading. Please reload this page.
Improve formatting of datatypes - #20605
Conversation
9b2c119 to
30f7fc8Compare30f7fc8 to
21e0efbCompareemilk
commented
Feb 28, 2026
oooops - sorry, didn't realize you were working on this :) Feel free to force-push again, and I'll go clean my apartment instead, like I should be doing… |
…ercion Use Arrow DataType Display style as the north-star: terse, readable type names instead of dumping internal Rust enum structure. - `dyn LogicalType`: delegates to NativeType Display instead of Debug, e.g. `Int32` instead of `LogicalType(Native(Int32), Int32)` - `TypeSignatureClass`: shows just the class name, e.g. `Numeric` instead of `TypeSignatureClass::Numeric` - `Coercion`: shows just the desired type, e.g. `Float64` instead of `Coercion(TypeSignatureClass::...)` - `ImplicitCoercion`: uses Display for its fields instead of Debug This dramatically improves error messages like: Before: `round(Coercion(TypeSignatureClass::Native(LogicalType(Native(Float64), Float64)), implicit_coercion=ImplicitCoercion([Numeric], default_type=Float64), ...)` After: `round(Float64, Int64)` Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
21e0efb to
aea6186Compare…n the snapshots, so just check the first part of the error message
timsaucer
left a comment
There was a problem hiding this comment.
Very nice cleanup! I'll leave it open for one more working day in case anyone else wants to chime in.
timsaucer
commented
Mar 2, 2026
Jefffrey
commented
Mar 2, 2026
I'll try take a look at this tomorrow |
We've updated to arrow 57, which _finally_ implements [proper `Display` formatting for `DataType`](apache/arrow-rs#8290). arrow-rs formats things slightly differently from how we have, but I think we should just converge on one standard here, in arrow-rs, and [in datafusion](apache/datafusion#20605). ## How to review Only look at changes in `.rs` files by [clicking here](https://github.com/rerun-io/reality/pull/967/changes?file-filters%5B%5D=.rs). Then take a look at a few snapshots Source-Ref: 8587961f0f1089a9a0f22c7e6a1cf907af81d0e6
Jefffrey
left a comment
There was a problem hiding this comment.
I think this is a very good step forward; we should leave the original issue open though as there's still improvements to be made to the error messages, but this PR really helps in cutting down the ugliness
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
## Which issue does this PR close? - Part of apache#19004 ## Rationale for this change Error messages should be friendly, short, and readable. ## What changes are included in this PR? * Implement proper `Display` for `dyn LogicalType`, `TypeSignature`, `TypeSignatureClass`, and `Coercion` instead of falling back to `Debug` * Switch error messages across the codebase from `{:?}` (`Debug`) to `{}` (`Display`) * Add `non-null` prefix for non-nullable fields in `NativeType` `Display`, following Arrow's convention The north star is to follow the convention set by arrow-rs ## Are these changes tested? New snapshot tests have been introduced, and existing ones updated. ## Are there any user-facing changes? Yes! #### Before > LogicalType(Native(List(LogicalField { name: "item", logical_type: LogicalType(Native(Int32), Int32), nullable: true })), List(LogicalField { name: "item", logical_type: LogicalType(Native(Int32), Int32), nullable: true })) #### After > List(Int32) #### Before ``` No function matches the given name and argument types 'round(Utf8, Utf8)'. Candidate functions: round(Coercion(TypeSignatureClass::Native(LogicalType(Native(Float64), Float64)), implicit_coercion=ImplicitCoercion([Numeric], default_type=Float64)), Coercion(TypeSignatureClass::Native(LogicalType(Native(Int64), Int64)), implicit_coercion=ImplicitCoercion([Integer], default_type=Int64))) Function 'abs' expects NativeType::Numeric but received NativeType::String Failed to coerce arguments: coercion from Int32, Utf8 to the signature Coercible([Coercion { desired_type: Native(LogicalType(Native(Float64), Float64)), ... }]) failed ``` #### After ``` No function matches the given name and argument types 'round(Utf8, Utf8)'. Candidate functions: round(Float64, Int64) Function 'abs' expects Numeric but received String Failed to coerce arguments: coercion from Int32, Utf8 to the signature Coercible(Float64, Int64) failed ``` --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Tim Saucer <timsaucer@gmail.com>
Three categories of fallout from the OneOf-signature-diagnostics cherry-pick that the upstream PR resolved via apache#20605 (formatting cleanup) but apache#20605 isn't on 52.5.0: 1. Two unused imports in datafusion-expr's test module (`IntervalUnit`, `logical_int64`) that compile-fail under `-D warnings` and trip clippy + lib-test builds. Dropped from the test imports in type_coercion/functions.rs. 2. Two sql-integration tests assert on the old `user-defined coercion failed with "..."` wording; updated to the new `failed with: ...` shape. 3. Eight sqllogictest expected-error patterns across arrow_typeof.slt, encoding.slt, expr.slt, scalar.slt, and datetime/timestamps.slt asserted on the old `Internal error: Expect TypeSignatureClass::X but received NativeType::Y` shape; updated to the new `Function 'NAME' requires TypeSignatureClass::X, but received Y (DataType: Y)` shape.
Cherry-pick of apache#21032. Adapted for 52.5.0: - Two unused imports in datafusion-expr's test module (`IntervalUnit`, `logical_int64`) compile-fail under -D warnings; dropped. - Two sql-integration tests and several sqllogictest expected-error patterns assumed the friendlier Display impl from apache#20605 was already on 52.5.0 (it isn't); updated those patterns to the pre-apache#20605 verbose `TypeSignatureClass::Native(LogicalType(...))` shape and to the post-apache#21032 `failed with: ...` (no quoted inner message) shape. - Also includes the author's own follow-up CI fix (was a separate commit upstream, folded here). Signed-off-by: yaommen <myanstu@163.com>
Cherry-pick of apache#21032. Adapted for 52.5.0: - Two unused imports in datafusion-expr's test module (`IntervalUnit`, `logical_int64`) compile-fail under -D warnings; dropped. - Two sql-integration tests and several sqllogictest expected-error patterns assumed the friendlier Display impl from apache#20605 was already on 52.5.0 (it isn't); updated those patterns to the pre-apache#20605 verbose `TypeSignatureClass::Native(LogicalType(...))` shape and to the post-apache#21032 `failed with: ...` (no quoted inner message) shape. - Also includes the author's own follow-up CI fix (was a separate commit upstream, folded here). Signed-off-by: yaommen <myanstu@163.com>
Cherry-pick of apache#21032. Adapted for 52.5.0: - Two unused imports in datafusion-expr's test module (`IntervalUnit`, `logical_int64`) compile-fail under -D warnings; dropped. - Two sql-integration tests and several sqllogictest expected-error patterns assumed the friendlier Display impl from apache#20605 was already on 52.5.0 (it isn't); updated those patterns to the pre-apache#20605 verbose `TypeSignatureClass::Native(LogicalType(...))` shape and to the post-apache#21032 `failed with: ...` (no quoted inner message) shape. - Also includes the author's own follow-up CI fix (was a separate commit upstream, folded here). Signed-off-by: yaommen <myanstu@163.com> (cherry picked from commit f478cdc)
Cherry-pick of apache#21032. Adapted for 52.5.0: - Two unused imports in datafusion-expr's test module (`IntervalUnit`, `logical_int64`) compile-fail under -D warnings; dropped. - Two sql-integration tests and several sqllogictest expected-error patterns assumed the friendlier Display impl from apache#20605 was already on 52.5.0 (it isn't); updated those patterns to the pre-apache#20605 verbose `TypeSignatureClass::Native(LogicalType(...))` shape and to the post-apache#21032 `failed with: ...` (no quoted inner message) shape. - Also includes the author's own follow-up CI fix (was a separate commit upstream, folded here). Signed-off-by: yaommen <myanstu@163.com> (cherry picked from commit f478cdc)
Which issue does this PR close?
Rationale for this change
Error messages should be friendly, short, and readable.
What changes are included in this PR?
Displayfordyn LogicalType,TypeSignature,TypeSignatureClass, andCoercioninstead of falling back toDebug{:?}(Debug) to{}(Display)non-nullprefix for non-nullable fields inNativeTypeDisplay, following Arrow's conventionThe north star is to follow the convention set by arrow-rs
Are these changes tested?
New snapshot tests have been introduced, and existing ones updated.
Are there any user-facing changes?
Yes!
Before
After
Before
After