-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix Infer prepare statement type tests #15743
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
base: main
Are you sure you want to change the base?
Conversation
…pare clause on the infer types tests
Projection: person.id, person.age | ||
Filter: person.age BETWEEN $1 AND $2 | ||
TableScan: person | ||
Prepare: "my_plan" [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently when the logical plan is created it does not include the type inferred, this result in some issues when we try to call the function plan.with_param_values(param_values)
as it tries to extract the type from the plan but it is empty. Are we expecting the plan to contain the type at this time? if so probably there is another bug we need to investigate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alamb @qstommyshu any advice on where to look to debug why the plan is not properly generating the inferred type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @brayanjuls ,
the reason why this happen is there is no parameters being passed to the sql, but the sql itself contains positional arguments like $1
and $2
, please refer to https://datafusion.apache.org/user-guide/sql/prepared_statements.html#inferred-types.
The simple way you can fix it is by adding the position arguments type to the sql
like how it was done in test_prepare_statement_to_plan_one_param
. If you want to dig into the details about it, you can check how planner parse PREPARE
statement and transfer it into a logical plan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but wouldn't that mean the type is not being inferred, but instead we are explicitly declaring it?
Thanks, I would check the planner parser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't check the details for parsing "PREPARE" statement yet, but I think the type inference behaviour depends on how the planner parser is implemented, it could be either way.
Which issue does this PR close?
Rationale for this change
This intent to correct issues on the prepare statements infer type tests. Currently they are not correctly asserting the expected behavior specially when we try to validate types.
What changes are included in this PR?
Are these changes tested?
Yes
Are there any user-facing changes?
No