Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-1450

Window function when window definition does not have order by clause would hit assertion error.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • None

    Description

      This query will hit as

      Q1:

      select sum(position_id) over w from cp.`employee.json` window w as ( partition by position_id)

      Stack trace:

      java.lang.AssertionError
      at org.eigenbase.sql.validate.SqlValidatorUtil.lookup(SqlValidatorUtil.java:242) ~[optiq-core-0.9-drill-r3.jar:na]
      at org.eigenbase.sql.SqlIdentifier.getMonotonicity(SqlIdentifier.java:261) ~[optiq-core-0.9-drill-r3.jar:na]
      at org.eigenbase.sql.validate.SelectScope.getMonotonicity(SelectScope.java:149) ~[optiq-core-0.9-drill-r3.jar:na]
      at org.eigenbase.sql.SqlWindow.isTableSorted(SqlWindow.java:340) ~[optiq-core-0.9-drill-r3.jar:na]
      at org.eigenbase.sql.SqlWindow.validate(SqlWindow.java:561) ~[optiq-core-0.9-drill-r3.jar:na]

      The cause of this issue is the star column in schema-less system. Drill currently will by default add "*" to a schema-less table. In optiq, * would be expanded to a list of regular columns if table is schema-aware, but does not expand for schema-less table (That's the behavior starting from optiq 0.9-drill-r2). That would cause issue in some optiq code logic, since it does not expect * ( should already be expanded).

      For Q1, we could remove the logic of adding * by default to schema-less table, and it would work fine. However, if the query explicitly ask for *, then still, run into similar problem:

      Q2:

      select *, sum(position_id) over w from cp.`employee.json` window w as ( partition by position_id)

      Therefore, the fix had better to be in Optiq.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jni Jinfeng Ni
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: