Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dynamic parameter expression #780

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions proto/substrait/algebra.proto
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@ message Expression {
Cast cast = 11;
Subquery subquery = 12;
Nested nested = 13;
DynamicParameter dynamic_parameter = 14;

// deprecated: enum literals are only sensible in the context of
// function arguments, for which FunctionArgument should now be
Expand Down Expand Up @@ -1604,6 +1605,16 @@ message Expression {
}
}

// Expression that represents a dynamic parameter.
// Dynamic parameters are identified by their 0-based index within a plan.
message DynamicParameter {
// The inferred type of the dynamic parameter.
jcamachor marked this conversation as resolved.
Show resolved Hide resolved
Type type = 1;

// The 0-based index of the dynamic parameter.
int32 index = 2;
jcamachor marked this conversation as resolved.
Show resolved Hide resolved
}

// The description of a field to sort on (including the direction of sorting and null semantics)
message SortField {
Expression expr = 1;
Expand Down
1 change: 1 addition & 0 deletions site/docs/expressions/_config
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ arrange:
- table_functions.md
- user_defined_functions.md
- embedded_functions.md
- dynamic_parameters.md
12 changes: 12 additions & 0 deletions site/docs/expressions/dynamic_parameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Dynamic Parameter Expression

The dynamic parameter expression represents a placeholder within an expression whose value is determined at runtime.
This is particularly useful for parameterized queries where certain values are not known until execution.
Additionally, using dynamic parameters can enable other use cases, such as sharing execution plans without embedding sensitive information.

A dynamic parameter expression includes the following properties:

| Property | Description | Required |
|----------|-----------------------------------------------------------------------------|----------|
| `type` | Specifies the expected data type of the dynamic parameter. | Yes |
| `index` | Indicates the 0-based position of the parameter within the plan. | Yes |
Loading