apache / apache/datafusion

Fix inconsistencies in type coercion logic

Open
#3,419 6 comments 0 reactions 0 assignees View on GitHub
bug optimizer
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

**Describe the bug**
The TypeCoercion rule incorrectly uses `coerce_types` (which should probably be renamed to `get_binary_op_type` because it determines the output type of a binary expression) to determine the types to case the lhs and rhs expressions.

I think we need a new and similar method for determining the common type to case inputs to, for binary expressions.

Maybe we need to introduce signatures for binary ops so this can be consolidated more, similar to how we handle UDF signatrures.

**To Reproduce**
Steps to reproduce the behavior:

**Expected behavior**
A clear and concise description of what you expected to happen.

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Research direction

Start with the TypeCoercion rule and its use of coerce_types for binary expressions. Determine how input coercion should be separated from determining a binary expression's output type, and clarify whether binary-operation signatures can consolidate this with UDF signatures; done means the inconsistency is resolved and binary coercion behaves consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.