Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Fix issue: sort order keyword is case sensitive (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
chloe-zh authored and penghuo committed Dec 15, 2020
1 parent 318aa20 commit 70ad207
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
6 changes: 6 additions & 0 deletions integ-test/src/test/resources/correctness/bugfixes/852.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT AvgTicketPrice FROM kibana_sample_data_flights ORDER BY AvgTicketPrice DESC
SELECT AvgTicketPrice FROM kibana_sample_data_flights ORDER BY AvgTicketPrice desc
SELECT AvgTicketPrice FROM kibana_sample_data_flights ORDER BY AvgTicketPrice DeSc
SELECT AvgTicketPrice FROM kibana_sample_data_flights ORDER BY AvgTicketPrice ASC
SELECT AvgTicketPrice FROM kibana_sample_data_flights ORDER BY AvgTicketPrice asc
SELECT AvgTicketPrice FROM kibana_sample_data_flights ORDER BY AvgTicketPrice AsC
2 changes: 2 additions & 0 deletions integ-test/src/test/resources/correctness/queries/orderby.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
SELECT FlightNum FROM kibana_sample_data_flights ORDER BY FlightNum
SELECT FlightNum FROM kibana_sample_data_flights ORDER BY FlightNum ASC
SELECT FlightNum FROM kibana_sample_data_flights ORDER BY FlightNum DESC
SELECT FlightNum FROM kibana_sample_data_flights ORDER BY FlightNum asc
SELECT FlightNum FROM kibana_sample_data_flights ORDER BY FlightNum desc
SELECT FlightNum, AvgTicketPrice FROM kibana_sample_data_flights ORDER BY FlightNum, AvgTicketPrice
SELECT FlightNum, AvgTicketPrice FROM kibana_sample_data_flights ORDER BY FlightNum DESC, AvgTicketPrice
SELECT FlightNum, AvgTicketPrice FROM kibana_sample_data_flights ORDER BY FlightNum, AvgTicketPrice DESC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private SortOrder visitSortOrder(Token ctx) {
if (ctx == null) {
return null;
}
return SortOrder.valueOf(ctx.getText());
return SortOrder.valueOf(ctx.getText().toUpperCase());
}

private NullOrder visitNullOrderClause(TerminalNode first, TerminalNode last) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,29 @@ public void can_build_order_by_null_option() {
buildAST("SELECT name FROM test ORDER BY name NULLS LAST"));
}

@Test
public void can_build_order_by_sort_order_keyword_insensitive() {
assertEquals(
project(
sort(
relation("test"),
field("age",
argument("asc", booleanLiteral(true)))),
alias("age", qualifiedName("age"))),
buildAST("SELECT age FROM test ORDER BY age ASC")
);

assertEquals(
project(
sort(
relation("test"),
field("age",
argument("asc", booleanLiteral(true)))),
alias("age", qualifiedName("age"))),
buildAST("SELECT age FROM test ORDER BY age asc")
);
}

@Test
public void can_build_from_subquery() {
assertEquals(
Expand Down

0 comments on commit 70ad207

Please sign in to comment.