Skip to content

Support with_parameter and with_parameters in query engine#125

Merged
ChunxuTang merged 12 commits intolance-format:mainfrom
leiyuou:yuolei/para
Feb 26, 2026
Merged

Support with_parameter and with_parameters in query engine#125
ChunxuTang merged 12 commits intolance-format:mainfrom
leiyuou:yuolei/para

Conversation

@leiyuou
Copy link
Contributor

@leiyuou leiyuou commented Feb 4, 2026

Support $param placeholder in query engine.
Supported Scalar Types:

Null
Boolean
Integer
Float
String

Supported Complex Types:

Float Vectors: Lists of numbers (e.g., [0.1, 0.2, 0.3]) are supported and converted to VectorLiteral (as Vec).

Key Changes:

  1. Stored user parameters in a HashMap<String, serde_json::Value> within the
    CypherQuery
  2. Propagated parameters to the semantic analysis layer, where they are resolved and validated.
  3. Implemented a parameter substitution pass (parameter_substitution.rs) that replaces parameter placeholders (e.g., $name) with their corresponding user-provided literal values (Scalar or Vector) directly in the AST before logical planning.
  4. Added end-to-end tests in tests/test_parameter_examples.rs (in plan) and verified existing tests to ensure correct parsing and execution of parameterized queries.

Closes #103.

@leiyuou leiyuou changed the title Support with_parameter and with_parameters in query engine Support with_parameter and with_parameters in query engine (WIP) Feb 4, 2026
@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2026

@leiyuou leiyuou changed the title Support with_parameter and with_parameters in query engine (WIP) Support with_parameter and with_parameters in query engine Feb 4, 2026
Copy link
Collaborator

@ChunxuTang ChunxuTang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leiyuou Thanks for the contribution! This is a very nice work.

I carefully re-evaluated the three design options for the parameter support, and I think it's better to go with option 1 (replacing the parameters during the semantic analysis pass). Could you update the PR?

@leiyuou leiyuou changed the title Support with_parameter and with_parameters in query engine Support with_parameter and with_parameters in query engine (WIP) Feb 12, 2026
Copy link
Collaborator

@ChunxuTang ChunxuTang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the update.
Just left some minor comments (mostly for code consistency).

@ChunxuTang ChunxuTang changed the title Support with_parameter and with_parameters in query engine (WIP) Support with_parameter and with_parameters in query engine Feb 26, 2026
Copy link
Collaborator

@ChunxuTang ChunxuTang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leiyuou Generally LGTM!

During the review, I found that the python_to_json method on the Python side actually doesn't support Python lists, so such a query would fail on the Python side:

query = (
    CypherQuery("MATCH (n:Item) WHERE vector_distance(n.embedding, $q, 'cosine') < 0.5 RETURN n")
    .with_config(config)
    .with_parameter("q", [0.1, 0.2, 0.3])  # ValueError raised here
)

Could you send a follow-up PR to fix the issue?

@ChunxuTang ChunxuTang merged commit af1e4bd into lance-format:main Feb 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Properly support parameter placeholders in Python/Rust

3 participants