[
https://issues.apache.org/jira/browse/CALCITE-3531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16982099#comment-16982099
]
Danny Chen edited comment on CALCITE-3531 at 11/26/19 3:16 AM:
---------------------------------------------------------------
I found this one in SQL standard 2011:
bq. Let S be an <SQL procedure statement> that is not generally contained in a
<triggered action>. All <datetime value function>s that are contained in <value
expression>s that are generally contained, without an intervening <routine
invocation> whose subject routines do not include an SQL function, either in S
without an intervening <SQL procedure statement> or in an <SQL procedure
statement> contained in the <triggered action> of a trigger activated as a
consequence of executing S, are effectively evaluated simultaneously. The time
of evaluation of a <datetime value function> during the execution of S and its
activated triggers is implementation-dependent.
But i'm not sure what it really means.
was (Author: danny0405):
I found this one in SQL standard 2011:
bq. Let S be an <SQL procedure statement> that is not generally contained in a
<triggered action>. All
bq. <datetime value function>s that are contained in <value expression>s that
are generally contained, without
bq. an intervening <routine invocation> whose subject routines do not include
an SQL function, either in S
bq. without an intervening <SQL procedure statement> or in an <SQL procedure
statement> contained in the
bq. <triggered action> of a trigger activated as a consequence of executing S,
are effectively evaluated simultaneously.
bq. The time of evaluation of a <datetime value function> during the execution
of S and its activated
bq. triggers is implementation-dependent.
But i'm not sure what it really means.
> AggregateProjectPullUpConstantsRule should not remove deterministic function
> group key if the function is dynamic
> -----------------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-3531
> URL: https://issues.apache.org/jira/browse/CALCITE-3531
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.21.0
> Reporter: Danny Chen
> Assignee: Danny Chen
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.22.0
>
> Time Spent: 2h 10m
> Remaining Estimate: 0h
>
> Now AggregateProjectPullUpConstantsRule simplify the query:
> {code:sql}
> select hiredate
> from sales.emp
> where sal is null and hiredate = current_timestamp
> group by sal, hiredate
> having count(*) > 3
> {code}
> from plan:
> {code:xml}
> LogicalProject(HIREDATE=[$1])
> LogicalFilter(condition=[>($2, 3)])
> LogicalAggregate(group=[{0, 1}], agg#0=[COUNT()])
> LogicalProject(SAL=[$5], HIREDATE=[$4])
> LogicalFilter(condition=[AND(IS NULL($5), =($4, CURRENT_TIMESTAMP))])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> to plan:
> {code:xml}
> LogicalProject(HIREDATE=[$1])
> LogicalFilter(condition=[>($2, 3)])
> LogicalProject(SAL=[$0], HIREDATE=[CURRENT_TIMESTAMP], $f2=[$1])
> LogicalAggregate(group=[{0}], agg#0=[COUNT()])
> LogicalProject(SAL=[$5], HIREDATE=[$4])
> LogicalFilter(condition=[AND(IS NULL($5), =($4,
> CURRENT_TIMESTAMP))])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> which is unsafe, because for stream sql, we need to group data by dateTime,
> also the result is wrong if a batch job runs across days.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)