Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow backtick around fields in sort cmd #1688

Merged
merged 4 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ gen

.java-version
.worktrees
http-client.env.json
http-client.env.json
/doctest/sql-cli/
.factorypath
7 changes: 5 additions & 2 deletions doctest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ def path = project(':').projectDir
// plugin module, and will only build ppl in it.
def plugin_path = project(':doctest').projectDir

task cloneSqlCli(type: Exec) {
task cloneSqlCli() {
Yury-Fridlyand marked this conversation as resolved.
Show resolved Hide resolved
// clone the sql-cli repo locally
commandLine 'git', 'clone', 'https://github.com/opensearch-project/sql-cli.git'
def cliRepo = new File("$projectDir/sql-cli")
if(!cliRepo.exists()) {
exec { commandLine 'git', 'clone', 'https://github.com/opensearch-project/sql-cli.git' }
}
}

task bootstrap(type: Exec, dependsOn: ['cloneSqlCli']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public UnresolvedExpression visitWcFieldExpression(WcFieldExpressionContext ctx)
@Override
public UnresolvedExpression visitSortField(SortFieldContext ctx) {
return new Field(
qualifiedName(ctx.sortFieldExpression().fieldExpression().getText()),
visit(ctx.sortFieldExpression().fieldExpression().qualifiedName()),
ArgumentFactory.getArgumentList(ctx)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@ public void testSortFieldWithMinusKeyword() {
));
}

@Test
public void testSortFieldWithBackticks() {
assertEqual("source=t | sort `f`",
sort(
relation("t"),
field("f", defaultSortFieldArgs())
));
}

@Test
public void testSortFieldWithAutoKeyword() {
assertEqual("source=t | sort auto(f)",
Expand Down