infiniflow / infiniflow/infinity

Thrift SDK to_string() misrenders zero-argument functions and IN/BETWEEN filters

Open Beginner friendly
#3,492 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
4.7k
Forks
445
Avg merge
2d 2h
Merged PRs (30d)
7

Description

Describe the bug

RemoteTable.to_string() misrenders three kinds of expressions in parsed_expression_to_string (python/infinity_sdk/infinity/remote_thrift/utils.py):

  1. Zero-argument functions. arguments_str is initialised to the str builtin, so a function with no arguments renders as row_id(<class 'str'>) instead of row_id().
  2. IN filters. The rendering is f"{left} IN (f{arguments_str})" - a stray literal f is prepended to the argument list: c1 IN (fc2, c3). With literal arguments (after the crash fix in #3441) it renders c1 IN (f1, 2, 3).
  3. BETWEEN. Same stray f on every operand, and the lower/upper bounds are printed swapped: with lower_bound=c2, upper_bound=c3 it renders between(fc1, fc3, fc2).

To Reproduce

from infinity.remote_thrift.infinity_thrift_rpc import ttypes
from infinity.remote_thrift.utils import parsed_expression_to_string

def col(name):
    return ttypes.ParsedExpr(type=ttypes.ParsedExprType(
        column_expr=ttypes.ColumnExpr(column_name=[name], star=False)))

f = ttypes.ParsedExpr(type=ttypes.ParsedExprType(
    function_expr=ttypes.FunctionExpr(function_name="row_id", arguments=[])))
print(parsed_expression_to_string(f))   # "row_id(<class 'str'>)"

i = ttypes.ParsedExpr(type=ttypes.ParsedExprType(
    in_expr=ttypes.InExpr(left_operand=col("c1"), arguments=[col("c2"), col("c3")], in_type=True)))
print(parsed_expression_to_string(i))   # "c1 IN (fc2, c3)"

b = ttypes.ParsedExpr(type=ttypes.ParsedExprType(
    between_expr=ttypes.BetweenExpr(value=col("c1"), lower_bound=col("c2"), upper_bound=col("c3"))))
print(parsed_expression_to_string(b))   # "between(fc1, fc3, fc2)" - f-prefix + bounds swapped

Verified on current main (eca7266), output identical across runs. Reachable through the public path, e.g. table.filter("row_id() = c2").to_string() renders "=(row_id(<class 'str'>), c2)".

Expected behavior

row_id(), c1 IN (c2, c3), between(c1, c2, c3).

Proposed fix

Join the arguments with ", ".join(...) instead of the manual arguments_str = str loop, drop the stray f prefixes, and print BETWEEN as (value, lower, upper).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in python/infinity_sdk/infinity/remote_thrift/utils.py at parsed_expression_to_string, then reproduce the three cases from the issue and the public table.filter(...).to_string() path. Done means zero-argument functions render as row_id(), IN filters have no stray f, and BETWEEN prints value, lower, upper in that order.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.