Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-545

When a projected expression can only have one value, replace with that constant

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.0-incubating
    • Component/s: None
    • Labels:
      None

      Description

      When we have deduced that an expression can only have one value, replace the expression with that value. This is beneficial because it will allow us to do more column trimming.

      Example 1

      select deptno from emp where deptno = 10

      can become

      select 10 from emp where deptno = 10

      Example 2 (using inference, as in CALCITE-360)

      select emp.deptno
      from emp join dept using (deptno)
      where dept.deptno = 10

      can become

      select 10
      from emp join dept using (deptno)
      where dept.deptno = 10

        Activity

        Hide
        julianhyde Julian Hyde added a comment -

        Ashutosh Chauhan This is the issue we discussed the other day. Anything I missed?

        Show
        julianhyde Julian Hyde added a comment - Ashutosh Chauhan This is the issue we discussed the other day. Anything I missed?
        Hide
        ashutoshc Ashutosh Chauhan added a comment -

        yup, these two covers those. Your second example I think will address this another form as well, which I am putting here only for completeness:

        SELECT src.key, src.key + 1, src2.value
               FROM src  join src2 ON src.key = src2.key AND src.key = 100;
        

        will become

        SELECT 100, 101, src2.value
               FROM src  join src2 ON src.key = src2.key AND src.key = 100;
        
        Show
        ashutoshc Ashutosh Chauhan added a comment - yup, these two covers those. Your second example I think will address this another form as well, which I am putting here only for completeness: SELECT src.key, src.key + 1, src2.value FROM src join src2 ON src.key = src2.key AND src.key = 100; will become SELECT 100, 101, src2.value FROM src join src2 ON src.key = src2.key AND src.key = 100;
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/c9e58edf .
        Hide
        julianhyde Julian Hyde added a comment -

        Closing now that 1.0.0-incubating has been released.

        Show
        julianhyde Julian Hyde added a comment - Closing now that 1.0.0-incubating has been released.

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            julianhyde Julian Hyde
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development