Skip to content

Commit

Permalink
Fixing qualified names in AstExpressionBuilder
Browse files Browse the repository at this point in the history
Signed-off-by: forestmvey <forestv@bitquilltech.com>
  • Loading branch information
forestmvey committed Mar 21, 2023
1 parent e7c449b commit 4e4f4a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void nested_with_date_type() {
rows("2017-10-12")
);
verifySchema(result,
schema("comments.data", null, "date"));
schema("comments.date", null, "date"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@
import org.opensearch.sql.ast.expression.When;
import org.opensearch.sql.ast.expression.WindowFunction;
import org.opensearch.sql.ast.tree.Sort.SortOption;
import org.opensearch.sql.common.antlr.SyntaxCheckException;
import org.opensearch.sql.common.utils.StringUtils;
import org.opensearch.sql.exception.SemanticCheckException;
import org.opensearch.sql.expression.function.BuiltinFunctionName;
import org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.AlternateMultiMatchQueryContext;
import org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.AndExpressionContext;
Expand Down Expand Up @@ -162,12 +160,22 @@ public UnresolvedExpression visitScalarFunctionCall(ScalarFunctionCallContext ct
public UnresolvedExpression visitNestedFunctionCall(NestedFunctionCallContext ctx) {
List<UnresolvedExpression> args = new ArrayList();

args.add(new QualifiedName(
StringUtils.unquoteText(ctx.nestedFunction().nestedField().getText()))
args.add(
new QualifiedName(
ctx.nestedFunction().nestedField().nestedIdent().stream()
.map(RuleContext::getText)
.map(StringUtils::unquoteIdentifier)
.collect(Collectors.toList())
)
);
if (ctx.nestedFunction().nestedPath() != null) {
args.add(new QualifiedName(
StringUtils.unquoteText(ctx.nestedFunction().nestedPath().getText()))
args.add(
new QualifiedName(
ctx.nestedFunction().nestedPath().nestedIdent().stream()
.map(RuleContext::getText)
.map(StringUtils::unquoteIdentifier)
.collect(Collectors.toList())
)
);
}

Expand Down Expand Up @@ -519,13 +527,6 @@ private Function buildFunction(String functionName,
);
}

private Function buildNestedFunction(String functionName, List<String> arg) {
return new Function(
functionName,
List.of(new QualifiedName(arg))
);
}

@Override
public UnresolvedExpression visitExtractFunctionCall(ExtractFunctionCallContext ctx) {
return new Function(
Expand Down

0 comments on commit 4e4f4a4

Please sign in to comment.