You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Donald,Zheng(vip.com)" <do...@vipshop.com> on 2016/09/22 02:43:32 UTC

答复: Discarding functionQuantifier in SqlCall.clone method leads to nullif function mistake

Thanks Julian.

JIRA issue has been created https://issues.apache.org/jira/browse/CALCITE-1381

-----邮件原件-----
发件人: Julian Hyde [mailto:jhyde@apache.org]
发送时间: 2016年9月22日 1:59
收件人: dev@calcite.apache.org
主题: Re: Discarding functionQuantifier in SqlCall.clone method leads to nullif function mistake

You’re correct.

Also, for efficiency I would override clone in SqlBasicCall, to avoid converting operands from an array to a list and back again.

Can you please log a JIRA case and provide a patch?

Julian

> On Sep 21, 2016, at 5:37 AM, Donald,Zheng(vip.com) <do...@vipshop.com> wrote:
>
> Hi all,
> I am new to Calcite.
> I found Calcite can’t execute queries like ‘select nullif(count(distinct colunm),0) from table ’, and dumped ‘Plan after trimming unused fields’ like this:
> LogicalProject(NAME=[$0], GENDER=[CASE(=($1, 0), null, CAST($2):BIGINT)])
>                         LogicalAggregate(group=[{0}], agg#0=[COUNT(DISTINCT $1)], agg#1=[COUNT($1)])
>                           LogicalProject(NAME=[$1], GENDER=[$3])
>                           CsvTableScan(table=[[SALES, EMPS]],
> fields=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) Then, I checked SqlNullifFunction rewriteCall method which used SqlNode.clone(SqlParserPos pos) method to create SqlCase call.
> Finally, the root cause I guess may be that the SqllCall.clone(SqlParserPos pos) method discard the functionQuantifier which holds such as ‘distinct’ symbol when create new SqlCall instance.
>
> Is there any special reason for the SqllCall.clone method implemented like this?
> and whether it has any side effects if I change the SqllCall.clone method as followed:
>
>    public SqlNode clone(SqlParserPos pos) {
>        List<? extends SqlNode> operandList = getOperandList();
>        return getOperator().createCall(getFunctionQuantifier(), pos, operandList.toArray(
>                new SqlNode[operandList.size()])); }
>
>
> Best regards.
>
> 本电子邮件可能为保密文件。如果阁下非电子邮件所指定之收件人,谨请立即通知本人。敬请阁下不要使用、保存、复印、打印、散布本电子邮件及其内容,或将其用于其他任何目的或向任何人披露。谢谢您的合作! This communication is intended only for the addressee(s) and may contain information that is privileged and confidential. You are hereby notified that, if you are not an intended recipient listed above, or an authorized employee or agent of an addressee of this communication responsible for delivering e-mail messages to an intended recipient, any dissemination, distribution or reproduction of this communication (including any attachments hereto) is strictly prohibited. If you have received this communication in error, please notify us immediately by a reply e-mail addressed to the sender and permanently delete the original e-mail communication and any attachments from all storage devices without making or otherwise retaining a copy.

本电子邮件可能为保密文件。如果阁下非电子邮件所指定之收件人,谨请立即通知本人。敬请阁下不要使用、保存、复印、打印、散布本电子邮件及其内容,或将其用于其他任何目的或向任何人披露。谢谢您的合作! This communication is intended only for the addressee(s) and may contain information that is privileged and confidential. You are hereby notified that, if you are not an intended recipient listed above, or an authorized employee or agent of an addressee of this communication responsible for delivering e-mail messages to an intended recipient, any dissemination, distribution or reproduction of this communication (including any attachments hereto) is strictly prohibited. If you have received this communication in error, please notify us immediately by a reply e-mail addressed to the sender and permanently delete the original e-mail communication and any attachments from all storage devices without making or otherwise retaining a copy.