Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
When there is a Sort RelNode that references an integer literal, the JDBC adapter converts this to a SQL ORDER BY clause that contains an integer literal as a sort key. Some dialects (most dialects, in fact) wrongly interpret as a reference to a field.
There is ambiguous in the rel-to-sql's converter when meeting `order by constant `.
Here is an example:
@Test void testOderByConstant() { final Function<RelBuilder, RelNode> relFn = b -> b .scan("EMP") .project(b.literal(1), b.field(1), b.field(2)) .sort(RelCollations.of(ImmutableList.of( new RelFieldCollation(0), new RelFieldCollation(1)))) .project(b.field(2), b.field(1)) .build(); final String expected = ""; relFn(relFn).ok(expected); }
Return sql:
SELECT "JOB", "ENAME" FROM "scott"."EMP" ORDER BY 1, "ENAME"
But, `ORDER BY 1` may mean 'sort by the first column in the select list' because of SqlConformance#isSortByOrdinal.
I keep this the same semantics, by apply the rule of `CoreRules#SORT_REMOVE_CONSTANT_KEYS`
Should the rel_to_sql's converter support it natively?
Attachments
Attachments
Issue Links
- links to