[teiid-issues] [JBoss JIRA] (TEIID-4113) Impala translator - Incorrect aggregate replacement in query
Don Krapohl (JIRA)
issues at jboss.org
Tue Apr 5 08:55:00 EDT 2016
[ https://issues.jboss.org/browse/TEIID-4113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13186745#comment-13186745 ]
Don Krapohl commented on TEIID-4113:
------------------------------------
Was trying that but with set showplan debug and the query:
We get this error and no plan, perhaps because the compile goes wrong:
set showplan debug;
SELECT trans_year,
cast(sum(num_items_net) / count(distinct case when order_pub_comm_base >= 0 then orderid end) as double) as net_items_per_order,
PARSETIMESTAMP(trans_date_key, 'yyyy-MM-dd')
FROM ActivityAdvertiserTransDate WHERE trans_date_key>='2015-01-01' AND trans_date_key<='2015-01-02'
AND advertiser_key=111 GROUP BY trans_year, trans_date_key
limit 1;
show plan;
set showplan off;
org.teiid.runtime.client.TeiidClientException: java.lang.RuntimeException: Remote org.teiid.core.TeiidProcessingException: TEIID30504 fact_activity_advertiser_trans_date: 500051 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: [] SQL: SELECT g_1.year_name AS c_0, cast((anon_grp0.agg0 / cast(anon_grp0.agg1 AS bigint)) AS double) AS c_1, g_0.trans_date_key AS c_2 FROM mart.fact_activity_advertiser_trans_date g_0 JOIN shared.dim_date g_1 ON g_0.trans_date_key = g_1.date_key WHERE g_0.trans_date_key >= '2015-01-01' AND g_0.trans_date_key <= '2015-01-02' AND g_0.advertiser_key = 111 AND g_1.date_key >= '2015-01-01' AND g_1.date_key <= '2015-01-02' GROUP BY g_1.year_name, g_0.trans_date_key LIMIT 1]
------------------
I've attached the plan without the parsetimestamp, which is what appears to be causing the issue.
> Impala translator - Incorrect aggregate replacement in query
> ------------------------------------------------------------
>
> Key: TEIID-4113
> URL: https://issues.jboss.org/browse/TEIID-4113
> Project: Teiid
> Issue Type: Bug
> Components: JDBC Connector
> Affects Versions: 8.13.3
> Environment: Ubuntu Trusty
> Reporter: Don Krapohl
> Assignee: Steven Hawkins
> Labels: Impala_Translator
>
> 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
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the teiid-issues
mailing list