infiniflow / infiniflow/infinity
[Bug]: embedded SDK crashes on UNNEST(...) in output columns
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 445
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 7
Description
## Problem
Selecting `unnest(...)` crashes the embedded SDK:
```python
from sqlglot import parse_one
from infinity_embedded.local_infinity.utils import parse_expr
parse_expr(parse_one("unnest(arr)"))
# Exception: unknown expression type: UNNEST(arr)
```
## Root cause
`exp.Unnest` carries its columns under the `expressions` arg **as a list**:
```python
>>> parse_one("unnest(arr)").args
{'expressions': [Column(this=Identifier(this=arr, quoted=False))]}
```
The embedded SDK's generic `exp.Func` arm in `python/infinity_embedded/local_infinity/utils.py` feeds every value in `cons.args.values()` to `parse_expr`, so the raw list hits `traverse_conditions`, matches no arm, and raises.
The thrift SDK handles `Unnest` explicitly inside its `Func` arm, and the server binder recognizes the `unnest` function (`src/planner/expression_binder_impl.cpp`), so this is an embedded-SDK-only gap.
## Fix
Add a dedicated `exp.Unnest` traversal arm (before the `Anonymous` / `Func` arms) that iterates `cons.args['expressions']` like the thrift SDK does.
Contributor guide
Research direction
Start in python/infinity_embedded/local_infinity/utils.py and compare the existing Unnest handling in the thrift SDK. Add the dedicated traversal arm before the Anonymous/Func arms, then verify parse_expr(parse_one("unnest(arr)")) no longer raises for the list under expressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100