jaystarshot commented on code in PR #2931: URL: https://github.com/apache/calcite/pull/2931#discussion_r994622813
########## core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java: ########## @@ -2815,6 +2815,45 @@ private SqlDialect nonOrdinalDialect() { sql(query).ok(expected); } + @Test public void testSelectQueryAliasInWhereClause() { + String query = "select \"cases_per_pallet\" as c from \"product\" where c > 100 "; + final String expected = "SELECT \"cases_per_pallet\" AS \"C\"\n" + + "FROM \"foodmart\".\"product\"\n" + + "WHERE \"cases_per_pallet\" > 100"; + sql(query).ok(expected); + } + + + @Test public void testSelectQueryAliasInSelectList() { + String query = "select \"cases_per_pallet\" as c, upper(c) from \"product\" ORDER BY c"; + final String expected = "SELECT \"cases_per_pallet\" AS \"C\", UPPER(CAST" + + "(\"cases_per_pallet\" AS VARCHAR CHARACTER SET \"ISO-8859-1\"))\n" + + "FROM \"foodmart\".\"product\"\n" + + "ORDER BY \"cases_per_pallet\""; + sql(query).ok(expected); + } + + @Test public void testSelectQueryAliasInOn() { + String query = "select \"employee_id\" as c, \"product_id\" p from \"product\" " + +" JOIN \"employee\" "+ + " ON c = p "; + final String expected = "SELECT \"employee\".\"employee_id\" AS \"C\", \"product\".\"product_id\" AS \"P\""+ + "FROM \"foodmart\".\"product\"" + + "INNER JOIN \"foodmart\".\"employee\" ON \"product\".\"product_id\" = \"employee\".\"employee_id\""; + sql(query).ok(expected); + } + + @Test public void testSelectQueryAliasPreferenceForInnerSubQuery() { + String query = "select \"employee_id\" as c, lower(c) from " + + "( SELECT \"employee_id\", \"gender\" AS c " + + "FROM \"employee\")"; + + final String expected = "SELECT \"employee_id\" AS \"C\", LOWER(\"gender\")\nFROM \"foodmart\".\"employee\""; + sql(query).ok(expected); + } + Review Comment: Hi Jiajun, thanks for the review and I am adding an alias test for group by but there is some error with conformance. Apparently group by alias is only allowed with the conformance isGroupByAlias true which is true for bigquery, mysql etc but when I run in my PR, it does not seem to recognize that conformance -- 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: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org