apache / apache/iceberg-python
Add `CAST` to `parser.py`
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 581
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 77
Description
### Feature Request / Improvement
I think I have somewhat of an idea on how to do this, so far have added the following to `parser.py`:
```py
CAST = CaselessKeyword("cast")
cast_expression = (CAST + "(" + column + "as" + identifier + Suppress(")")).set_results_name("cast")
# would need something special for the set_parse_action
```
I am wondering a couple of things:
Do we need a new class `CastableReference` or something? Worth expanding on the `Reference` class? And once that is done, how would we propagate the new type (Im assuming we need some way to go from a string to an `IcebergType` of the string the user has put into the cast operation) into the scan?
This was spawned from https://github.com/apache/iceberg-python/issues/170
Happy to work on this, just would be awesome to get some context
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with parser.py and the context in issue 170. Trace the existing Reference class and parse actions, then follow how parsed expressions reach the scan and how strings become IcebergType values. Done means CAST syntax is parsed and its target type is propagated into the scan.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100