dssysolyatin commented on code in PR #3022:
URL: https://github.com/apache/calcite/pull/3022#discussion_r1068114659
##########
core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java:
##########
@@ -4769,4 +4769,18 @@ void checkUserDefinedOrderByOver(NullCollation
nullCollation) {
String sql = "SELECT CAST(CAST(? AS INTEGER) AS CHAR)";
sql(sql).ok();
}
+
+ /**
+ * Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5468">[CALCITE-5468]
+ * SqlToRelConverter should register sub-queries inside ORDER BY clause
+ * for queries without aggregation</a>.
+ */
+ @Test void testOrderByWithSubQuery() {
+ String sql = "SELECT empno\n"
+ + "FROM emp\n"
+ + "ORDER BY\n"
+ + "CASE WHEN empno IN (1,2) THEN 0 ELSE 1 END";
+ sql(sql).ok();
+ }
Review Comment:
Yes, IN is not subquery in terms of SQL. But inside codebase there are
places with code like:
```
/**
* Scalar expression that represents an IN, EXISTS or scalar sub-query.
*/
public class RexSubQuery extends RexCall
```
It is actually quite confusing.
I renamed test and added test for subquery.
--
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]