[Bug]: embedded SDK crashes on TRIM variants (LTRIM/RTRIM/position/character) in output columns
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start at parse_expr in python/infinity_embedded/local_infinity/utils.py and inspect the generic exp.Func handling alongside the thrift SDK's Trim mapping. Check the registered server functions in src/function/scalar/trim_impl.cpp, ltrim_impl.cpp, and rtrim_impl.cpp. Done means trim, ltrim, and rtrim variants with position or character arguments no longer raise the unknown expression type error.
Written by the indexing model from the issue text.
Description
Problem
Any TRIM variant beyond a bare trim(col) crashes the embedded SDK:
from sqlglot import parse_one
from infinity_embedded.local_infinity.utils import parse_expr
parse_expr(parse_one("trim(both ' ' from name)")) # Exception: unknown expression type: TRIM(name, ' ')
parse_expr(parse_one("trim(leading 'x' from name)")) # same
parse_expr(parse_one("ltrim(name)")) # same
Root cause
sqlglot parses all of these — including ltrim(...) / rtrim(...) — as exp.Trim, whose position arg is a plain string ('LEADING' / 'TRAILING' / 'BOTH') and whose expression arg is the character literal:
>>> parse_one("trim(both ' ' from name)").args
{'this': Column(...), 'position': 'BOTH', 'expression': Literal(...), 'collation': None}
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, and the raw string 'BOTH' (or the character literal) matches no arm and raises.
The thrift SDK maps Trim to the server's trim / ltrim / rtrim by position, and the server registers all three (src/function/scalar/trim_impl.cpp, ltrim_impl.cpp, rtrim_impl.cpp).
Fix
Add a dedicated exp.Trim arm before the generic Func arm that maps the position flag to trim / ltrim / rtrim, mirroring the thrift SDK.
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 445
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from infiniflow/infinity
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
infiniflow/infinity#3502 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infiniflow/infinity#3500 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
infiniflow/infinity#3492 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
infiniflow/infinity#3491 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
infiniflow/infinity#3484 ·
All issues in infiniflow/infinity
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·