[
https://issues.apache.org/jira/browse/CALCITE-5895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17751318#comment-17751318
]
LakeShen commented on CALCITE-5895:
-----------------------------------
Hi [~Runking] ,thanks for your reply.I also found this comment in
parser.jj.Anyway, it's a problem of data correctness.
I had the same thought with you and made 'TABLESAMPLE(0)' return empty result.
I have two implementations to solve this problem,an Implementation is:
1. Make sure the AST tree (SqlNode) structure is correct
2. Add an optimization rule to convert Sample(rate = 0) to empty LogicalValues.
Above is the logic for processing Sample(rate=0) handled in Presto.
Another implementations is:
1. Make sure the AST tree structure is correct.
2. In SqlToRelConverter class,when do convertFrom logic,if find the table
sample rate is 0,then convert it to empty LogicalValues.
The first implementation is more flexible and will be simpler to implement, but
it adds an optimization rule.
The second implementation involves the logic of SqlToRelConverter, which can be
a bit difficult to implement.
Currently I prefer the first one.If anyone else has any suggestions, feel free
to share them:)
> The result of table sample rate 0 is incorrect result
> ------------------------------------------------------
>
> Key: CALCITE-5895
> URL: https://issues.apache.org/jira/browse/CALCITE-5895
> Project: Calcite
> Issue Type: Bug
> Reporter: LakeShen
> Priority: Major
> Fix For: 1.36.0
>
> Attachments: image-2023-08-05-22-45-02-513.png
>
>
> For The sql:
> {code:java}
> select * from emp tablesample bernoulli(0) where empno > 5
> {code}
> The plan is :
> {code:java}
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4],
> SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
> LogicalFilter(condition=[>($0, 5)])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> I think the correct result of above SQL is empty.
> But its result is the following SQL result:
> {code:java}
> select * from emp where empno > 5
> {code}
> It's an incorrect result
--
This message was sent by Atlassian Jira
(v8.20.10#820010)