apache / apache/datafusion

Ability to inspect type of an expression

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

Description

### Is your feature request related to a problem or challenge?

I as a user want to be able to inspect type of expressions. Example usage is to inspect different sides of the comparison (column vs expression) to make sure there is no implicit cast preventing or limiting predicate pushdown.
The type inspection should also help me write a CAST.

### Describe the solution you'd like

A function similar to `arrow_typeof` which reveals the SQL type of an expression.

### Describe alternatives you've considered

Using `arrow_typeof` function. Teturn result of that function cannot be used in a CAST:
```
DataFusion CLI v41.0.0
> SELECT arrow_typeof('a');
+-------------------------+
| arrow_typeof(Utf8("a")) |
+-------------------------+
| Utf8 |
+-------------------------+
1 row(s) fetched.
Elapsed 0.015 seconds.

> SELECT CAST('a' AS Utf8);
This feature is not implemented: Unsupported SQL type Custom(ObjectName([Ident { value: "Utf8", quote_style: None }]), [])
```

### Additional context

None

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing `arrow_typeof` function and the SQL `CAST` handling described in the issue. Compare how each represents expression types and identify the design needed for a function that exposes a SQL type usable in a CAST. Done means the requested expression type inspection works for the stated comparison and casting use cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.