[
https://issues.apache.org/jira/browse/CALCITE-5895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17751317#comment-17751317
]
Runkang He commented on CALCITE-5895:
-------------------------------------
I wonder whether this is by design or not. Currently in core parser,
`TABLESAMPLE(0)` is just ignored, and returns the full result, IMO this is
because table sample allows to return more than the specified rate rows.
The more detail is in [Parser.jj's
comment|https://github.com/apache/calcite/blob/98f3048fb1407e2878162ffc80388d4f9dd094b2/core/src/main/codegen/templates/Parser.jj#L2298]:
`TABLESAMPLE(0)` should produce no output, but it simplifies implementation to
know that some amount of sampling will occur.
But I think it's more reasonable to improve the implementation for
`TABLESAMPLE(0)`, to return empty result.
> 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)