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

Extend ‘Must-filter’ columns to support a conditional bypass list

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.39.0
    • None

    Description

      In CALCITE-6219 we introduced interface SemanticTable. A table that implements this interface can define fields to be ‘must-filter’; a query that does not filter those fields in its WHERE or HAVING clause will throw a validation error.

      In this case, we allow a SemanticTable to have a list of bypass fields. If a query filters on any bypass field in its WHERE or HAVING clause, then the must-filter fields are ignored. 

      For example, the EMP table specifies must-filter-fields EMPNO and DEPTNO,
      and bypass-fields ENAME and SALARY. Consider the following queries on EMP.

      // Valid. Query filters on both must-filter fields.
      SELECT * FROM EMP WHERE EMPNO = 1 and DEPTNO = 2;
      
      // Invalid. Query does not filter on must-filter field 'DEPTNO'.
      SELECT * FROM EMP WHERE EMPNO = 1;
      
      // Valid. Query filters on bypass field 'ENAME', and therefore does not
      // need to filter on the must-filter field 'DEPTNO'.
      SELECT * FROM EMP WHERE EMPNO = 1 and ENAME = ’name’ ;
      
      // Valid. Query filters on bypass field 'ENAME', and therefore does not
      // need to filter on any must-filter field.
      SELECT * FROM EMP WHERE ENAME = ’name’;
      
      // Valid. Query filters on bypass field 'SALARY', and therefore does not
      // need to filter on any must-filter field.
      SELECT * FROM EMP WHERE SALARY > 10;
      

       
      As for must-filter fields, there are special considerations are for handling joins, CTEs and subqueries. We therefore include a comprehensive suite of tests, as we did for CALCITE-6219.

      Attachments

        Issue Links

          Activity

            People

              oliverlee Oliver Lee
              oliverlee Oliver Lee
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: