Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-9809

[Rust] [DataFusion] logical schema = physical schema is not true

    XMLWordPrintableJSON

Details

    Description

      In tests/sql.rs, we test that the physical and the optimized schema must match. However, this is not necessarily true for all our queries. An example:

      #[test]
      fn csv_query_sum_cast() {
          let mut ctx = ExecutionContext::new();
          register_aggregate_csv_by_sql(&mut ctx);
          // c8 = i32; c9 = i64
          let sql = "SELECT c8 + c9 FROM aggregate_test_100";
          // check that the physical and logical schemas are equal
          execute(&mut ctx, sql);
      }
      

      The physical expression (and schema) of this operation, after optimization, is CAST(c8 as Int64) Plus c9 (this test fails).

      AFAIK, the invariant of the optimizer is that the output types and nullability are the same.

      Also, note that the reason the optimized logical schema equals the logical schema is that our type coercer does not change the output names of the schema, even though it re-writes logical expressions. I.e. after the optimization, `.to_field()` of an expression may no longer match the field name nor type in the Plan's schema. IMO this is currently by (implicit?) design, as we do not want our logical schema's column names to change during optimizations, or all column references may point to non-existent columns. This is something that brought up on the mailing list about polymorphism.

      Attachments

        Issue Links

          Activity

            People

              jorgecarleitao Jorge Leitão
              jorgecarleitao Jorge Leitão
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m