suibianwanwank commented on code in PR #4181:
URL: https://github.com/apache/calcite/pull/4181#discussion_r1952884246
##########
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java:
##########
@@ -8577,6 +8577,111 @@ private void checkSemiJoinRuleOnAntiJoin(RelOptRule
rule) {
.check();
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6652">[CALCITE-6652]
+ * RelDecorrelator can't decorrelate query with limit 1</a>.
+ */
+ @Test void testDecorrelateProjectWithFetchOne() {
+ final String query = "SELECT name, "
+ + "(SELECT sal FROM emp where dept.deptno = emp.deptno order by sal
limit 1) "
+ + "FROM dept";
+ sql(query).withRule(CoreRules.PROJECT_SUB_QUERY_TO_CORRELATE)
+ .withLateDecorrelate(true)
+ .check();
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6652">[CALCITE-6652]
+ * RelDecorrelator can't decorrelate query with limit 1</a>.
+ */
+ @Test void testDecorrelateProjectWithFetchOneDesc() {
+ final String query = "SELECT name, "
+ + "(SELECT emp.sal FROM emp WHERE dept.deptno = emp.deptno "
+ + "ORDER BY emp.sal desc nulls last LIMIT 1) "
+ + "FROM dept";
+ sql(query).withRule(CoreRules.PROJECT_SUB_QUERY_TO_CORRELATE)
+ .withLateDecorrelate(true)
+ .check();
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6652">[CALCITE-6652]
+ * RelDecorrelator can't decorrelate query with limit 1</a>.
+ */
+ @Test void testDecorrelateFilterWithFetchOne() {
+ final String query = "SELECT name FROM dept "
+ + "WHERE 10 > (SELECT emp.sal FROM emp where dept.deptno = emp.deptno "
+ + "ORDER BY emp.sal desc nulls last limit 1)";
+ sql(query).withRule(CoreRules.FILTER_SUB_QUERY_TO_CORRELATE)
+ .withLateDecorrelate(true)
+ .check();
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6652">[CALCITE-6652]
+ * RelDecorrelator can't decorrelate query with limit 1</a>.
+ */
+ @Test void testDecorrelateFilterWithFetchOneDesc() {
+ final String query = "SELECT name FROM dept "
Review Comment:
Thanks for catching that! I've fixed it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]