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

Fix issue: sort order keyword is case sensitive #853

Merged
merged 1 commit into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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