infiniflow / infiniflow/infinity

[Bug]: embedded SDK rejects all LIKE / NOT LIKE / ESCAPE filters

Open
#3,465 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
4.7k
Forks
445
Avg merge
2d 2h
Merged PRs (30d)
7

Description

## Problem

Every `LIKE` filter crashes in the embedded SDK (`python/infinity_embedded/local_infinity/utils.py`):

```python
from sqlglot import condition
from infinity_embedded.local_infinity.utils import traverse_conditions

traverse_conditions(condition("name LIKE 'a%'")) # InfinityException: unknown binary expression: like
traverse_conditions(condition("name NOT LIKE 'a%'")) # same
traverse_conditions(condition("name LIKE 'a!%' ESCAPE '!'")) # InfinityException: unknown binary expression: escape
```

## Root cause

`exp.Like` and `exp.Escape` are sqlglot `Binary` subclasses, so they fall into the generic `Binary` arm of `traverse_conditions`, which maps the operator through `binary_exp_to_paser_exp()`. The embedded operator map (`python/infinity_embedded/utils.py`) has no `like` / `notlike` / `escape` entries, so every LIKE filter raises.

The thrift SDK supports LIKE (dedicated arms + map entries) and the server registers both `like` and `not_like` (`src/function/scalar/like_impl.cpp`), so this is purely an embedded-SDK gap.

## Fix

- Add `like` / `notlike` entries to the embedded operator map.
- Add dedicated `exp.Like` / `exp.Escape` traversal arms mirroring the thrift SDK (left, pattern, escape as the third argument), honoring the sqlglot >= 30.x `Like(negate=True)` form of `NOT LIKE`.
- Narrow the generic `Binary` arm so `Like` / `Escape` reach the dedicated arms.

Contributor guide

Open the contributing guide

Research direction

Start at traverse_conditions in python/infinity_embedded/local_infinity/utils.py and compare its handling with the thrift SDK. Then inspect the operator map in python/infinity_embedded/utils.py and the LIKE implementation reference in src/function/scalar/like_impl.cpp. Done means the three provided LIKE, NOT LIKE, and ESCAPE examples no longer raise an unknown-expression error and pass the correct operands.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.