Skip to content

Commit 4eaf8bb

Browse files
joshuali925MitchellGale
authored andcommitted
Allow backtick around fields in sort cmd (opensearch-project#1688)
* Allow backtick around fields in sort cmd Signed-off-by: Joshua Li <[email protected]> * Add test Signed-off-by: Joshua Li <[email protected]> * Update test setup Signed-off-by: Joshua Li <[email protected]> * revert ignoring sql-cli repo if exists Signed-off-by: Joshua Li <[email protected]> --------- Signed-off-by: Joshua Li <[email protected]> Signed-off-by: Mitchell Gale <[email protected]>
1 parent 99928e6 commit 4eaf8bb

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ gen
4747

4848
.java-version
4949
.worktrees
50-
http-client.env.json
50+
http-client.env.json
51+
/doctest/sql-cli/
52+
.factorypath

ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public UnresolvedExpression visitWcFieldExpression(WcFieldExpressionContext ctx)
182182
@Override
183183
public UnresolvedExpression visitSortField(SortFieldContext ctx) {
184184
return new Field(
185-
qualifiedName(ctx.sortFieldExpression().fieldExpression().getText()),
185+
visit(ctx.sortFieldExpression().fieldExpression().qualifiedName()),
186186
ArgumentFactory.getArgumentList(ctx)
187187
);
188188
}

ppl/src/test/java/org/opensearch/sql/ppl/parser/AstExpressionBuilderTest.java

+9
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,15 @@ public void testSortFieldWithMinusKeyword() {
301301
));
302302
}
303303

304+
@Test
305+
public void testSortFieldWithBackticks() {
306+
assertEqual("source=t | sort `f`",
307+
sort(
308+
relation("t"),
309+
field("f", defaultSortFieldArgs())
310+
));
311+
}
312+
304313
@Test
305314
public void testSortFieldWithAutoKeyword() {
306315
assertEqual("source=t | sort auto(f)",

0 commit comments

Comments
 (0)