Skip to content

Include datatypes in logicalplan for inferred statements #16018

@brayanjuls

Description

@brayanjuls

Given a prepare statement: PREPARE my_plan AS SELECT id, age FROM person WHERE age BETWEEN $1 AND $2

The generated logical plan would look like this:


Prepare: "my_plan" [] 
  Projection: person.id, person.age
    Filter: person.age BETWEEN $1 AND $2
      TableScan: person

As you can see from the previous plan we don’t include the datatypes in it, so when we try to replace the params with values to assert the replacement it will fail.

replace params with values:

    let param_values = vec![ScalarValue::Int32(Some(10)), ScalarValue::Int32(Some(30))];
    let plan_with_params = plan.with_param_values(param_values).unwrap(); // This execution will fail as the input param values and the data types are of different size

    assert_snapshot!(
        plan_with_params,
        @r"
    Projection: person.id, person.age
      Filter: person.age BETWEEN Int32(10) AND Int32(30)
        TableScan: person
    "
    );

It is expected the datatypes to be included in the logicalplan by inferring them when they are not explicitly declared. The discussion around this happened in the following PR.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions