apache / apache/datafusion

CLI query result header for cast expressions with literals is confusing

Open
#5,221 7 comments 1 reaction 1 assignee Claimed by @qstommyshu View on GitHub
bug
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

**Describe the bug**
the header produces the type and value of the cast input rather than of the cast output which looks like a NOP in some situations and hard to recognize

**To Reproduce**
```
❯ select cast('1' as int);
+-----------+
| Utf8("1") |
+-----------+
| 1 |
+-----------+
1 row in set. Query took 0.000 seconds.
❯ select cast(1 as string);
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+
1 row in set. Query took 0.000 seconds.
```

**Expected behavior**
Use some indication of the cast being applied.
E.g. use the output expression name or part of it
`Utf8("1") AS Int64(1) `

```
❯ explain select cast(1 as string);
+---------------+--------------------------------------+
| plan_type | plan |
+---------------+--------------------------------------+
| logical_plan | Projection: Utf8("1") AS Int64(1) |
| | EmptyRelation |
| physical_plan | ProjectionExec: expr=[1 as Int64(1)] |
| | EmptyExec: produce_one_row=true |
| | |
+---------------+--------------------------------------+
2 rows in set. Query took 0.000 seconds.
```

**Additional context**
n/a

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.