Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-4113

Impala translator - Incorrect aggregate replacement in query

XMLWordPrintable

      When PARSETIMESTAMP is included in a query aggregates in other columns may not be written correctly. Example is as below, sum(first_metric) is rewritten to anon_grp0.agg0 in the query sent to Impala.

      Given the schema:
      //source
      SourceTable
      the_attribute string(255),
      first_metric long,
      second_metric bigdecimal
      another_attribute String(255)

      //view
      VirtualTable
      the_attribute string(255),
      first_metric long,
      second_metric bigdecimal
      another_attribute String(255)

      // Teiid query
      SELECT the_attribute,
      cast(
      sum(
      first_metric
      )
      /
      count(
      distinct case when second_metric >= 0 then second_metric end
      ) as double
      ) as some_alias,
      PARSETIMESTAMP(another_attribute, 'yyyy-MM-dd') as somedate
      FROM VirtualTable
      WHERE a_filter_val=111
      GROUP BY the_attribute, another_attribute

      //Query sent to impala
      SELECT g_0.the_attribute AS c_0,
      cast(
      (
      anon_grp0.agg0
      /
      cast(
      anon_grp0.agg1 AS bigint
      )
      ) AS double
      ) AS c_1,
      g_0.another_attribute AS c_2
      FROM VirtualTable
      WHERE a_filter_val=111
      GROUP BY g_0.the_attribute, g_0.another_attribute

              rhn-engineering-shawkins Steven Hawkins
              dkrapohl@hotmail.com Donald Krapohl (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: