Skip to content

Improve formatting of datatypes#20605

Open
emilk wants to merge 6 commits intoapache:mainfrom
rerun-io:emilk/improve-errors
Open

Improve formatting of datatypes#20605
emilk wants to merge 6 commits intoapache:mainfrom
rerun-io:emilk/improve-errors

Conversation

@emilk
Copy link
Contributor

@emilk emilk commented Feb 27, 2026

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?

  • 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

emilk and others added 4 commits February 27, 2026 18:41
…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>
@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt) common Related to common crate functions Changes to functions implementation physical-plan Changes to the physical-plan crate labels Feb 27, 2026
@github-actions github-actions bot added the sql SQL Planner label Feb 27, 2026
@timsaucer timsaucer self-requested a review February 27, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate functions Changes to functions implementation logical-expr Logical plan and expressions optimizer Optimizer rules physical-plan Changes to the physical-plan crate sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error messages when coercion fails

1 participant