From 3aa5aacc5fc72c6e2ae6ce54f6cc7c32edc35e7e Mon Sep 17 00:00:00 2001 From: Dai Date: Mon, 11 Jan 2021 13:35:16 -0800 Subject: [PATCH 1/7] Change grammar and UT --- docs/experiment/ppl/general/identifiers.rst | 2 ++ ppl/src/main/antlr/OpenDistroPPLLexer.g4 | 1 + ppl/src/main/antlr/OpenDistroPPLParser.g4 | 1 + .../sql/ppl/parser/AstBuilder.java | 2 +- .../sql/ppl/parser/AstExpressionBuilder.java | 16 +++++++++++----- .../sql/ppl/parser/AstBuilderTest.java | 5 ++--- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/docs/experiment/ppl/general/identifiers.rst b/docs/experiment/ppl/general/identifiers.rst index 1a3aa70147..60c3997c0e 100644 --- a/docs/experiment/ppl/general/identifiers.rst +++ b/docs/experiment/ppl/general/identifiers.rst @@ -30,6 +30,8 @@ For Elasticsearch, the following identifiers are supported extensionally: 3. Identifiers with ``-`` in the middle: this is mostly the case for index name with date information. 4. Identifiers with star ``*`` present: this is mostly an index pattern for wildcard match. +Index name with date suffix separated by dash or dots, such as ``cwl-2020.01.11`` or ``logs-7.0-2020.01.11``, is common for those created by Logstash or FileBeat ingestion. So, this kind of identifier used as index name is also supported without the need of being quoted for user convenience. + Examples -------- diff --git a/ppl/src/main/antlr/OpenDistroPPLLexer.g4 b/ppl/src/main/antlr/OpenDistroPPLLexer.g4 index 15b8830a31..d776bf0681 100644 --- a/ppl/src/main/antlr/OpenDistroPPLLexer.g4 +++ b/ppl/src/main/antlr/OpenDistroPPLLexer.g4 @@ -242,6 +242,7 @@ INTEGER_LITERAL: DEC_DIGIT+; DECIMAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+; fragment ID_LITERAL: [@*A-Z]+?[*A-Z_\-0-9]*; +ID_DOT: ID_LITERAL ([\-.][0-9]+)*; DQUOTA_STRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"'; SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\''; BQUOTA_STRING: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`'; diff --git a/ppl/src/main/antlr/OpenDistroPPLParser.g4 b/ppl/src/main/antlr/OpenDistroPPLParser.g4 index d724beb0de..80a280e54a 100644 --- a/ppl/src/main/antlr/OpenDistroPPLParser.g4 +++ b/ppl/src/main/antlr/OpenDistroPPLParser.g4 @@ -178,6 +178,7 @@ booleanExpression /** tables */ tableSource : qualifiedName + | ID_DOT ; /** fields */ diff --git a/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilder.java b/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilder.java index abe8680175..8a8c011190 100644 --- a/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilder.java +++ b/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilder.java @@ -267,7 +267,7 @@ public UnresolvedPlan visitTopCommand(TopCommandContext ctx) { */ @Override public UnresolvedPlan visitFromClause(FromClauseContext ctx) { - return new Relation(visitExpression(ctx.tableSource().qualifiedName())); + return new Relation(visitExpression(ctx.tableSource())); } /** diff --git a/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilder.java b/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilder.java index 729b4ba0a9..d835d0aedb 100644 --- a/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilder.java +++ b/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilder.java @@ -18,8 +18,10 @@ import static com.amazon.opendistroforelasticsearch.sql.expression.function.BuiltinFunctionName.IS_NOT_NULL; import static com.amazon.opendistroforelasticsearch.sql.expression.function.BuiltinFunctionName.IS_NULL; import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.BinaryArithmeticContext; +import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.BooleanFunctionCallContext; import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.BooleanLiteralContext; import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.CompareExprContext; +import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.CountAllFunctionCallContext; import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.DecimalLiteralContext; import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.EvalClauseContext; import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.EvalFunctionCallContext; @@ -38,6 +40,7 @@ import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.SortFieldContext; import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.StatsFunctionCallContext; import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.StringLiteralContext; +import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.TableSourceContext; import static com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser.WcFieldExpressionContext; import com.amazon.opendistroforelasticsearch.sql.ast.expression.AggregateFunction; @@ -59,7 +62,6 @@ import com.amazon.opendistroforelasticsearch.sql.ast.expression.UnresolvedExpression; import com.amazon.opendistroforelasticsearch.sql.ast.expression.Xor; import com.amazon.opendistroforelasticsearch.sql.common.utils.StringUtils; -import com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParser; import com.amazon.opendistroforelasticsearch.sql.ppl.antlr.parser.OpenDistroPPLParserBaseVisitor; import com.amazon.opendistroforelasticsearch.sql.ppl.utils.ArgumentFactory; import com.google.common.collect.ImmutableMap; @@ -183,8 +185,7 @@ public UnresolvedExpression visitStatsFunctionCall(StatsFunctionCallContext ctx) } @Override - public UnresolvedExpression visitCountAllFunctionCall( - OpenDistroPPLParser.CountAllFunctionCallContext ctx) { + public UnresolvedExpression visitCountAllFunctionCall(CountAllFunctionCallContext ctx) { return new AggregateFunction("count", AllFields.of()); } @@ -198,8 +199,7 @@ public UnresolvedExpression visitPercentileAggFunction(PercentileAggFunctionCont * Eval function. */ @Override - public UnresolvedExpression visitBooleanFunctionCall( - OpenDistroPPLParser.BooleanFunctionCallContext ctx) { + public UnresolvedExpression visitBooleanFunctionCall(BooleanFunctionCallContext ctx) { final String functionName = ctx.conditionFunctionBase().getText(); return new Function( @@ -225,6 +225,12 @@ public UnresolvedExpression visitEvalFunctionCall(EvalFunctionCallContext ctx) { .collect(Collectors.toList())); } + @Override + public UnresolvedExpression visitTableSource(TableSourceContext ctx) { + return new QualifiedName(Collections.singletonList( + StringUtils.unquoteIdentifier(ctx.getText()))); + } + /** * Literal and value. */ diff --git a/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java b/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java index 7565f52e8c..51fbb7bfdb 100644 --- a/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java +++ b/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java @@ -379,9 +379,8 @@ public void testIdentifierAsIndexNameStartWithDot() { } @Test - public void identifierAsIndexNameWithDotInTheMiddleThrowException() { - exceptionRule.expect(SyntaxCheckException.class); - plan("source=log.2020.10.10"); + public void testIdentifierAsIndexNameWithDotInTheMiddle() { + assertEqual("source=log.2020.10.10", relation("log.2020.10.10")); } @Test From 32f8d628467af322b189adac0629ecf364dc667d Mon Sep 17 00:00:00 2001 From: Dai Date: Mon, 11 Jan 2021 14:51:20 -0800 Subject: [PATCH 2/7] Add more UT and IT --- .../sql/ppl/SearchCommandIT.java | 10 ++++++++++ .../sql/ppl/parser/AstBuilderTest.java | 1 + 2 files changed, 11 insertions(+) diff --git a/integ-test/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/SearchCommandIT.java b/integ-test/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/SearchCommandIT.java index 6bdad4ed10..4b98b42ca1 100644 --- a/integ-test/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/SearchCommandIT.java +++ b/integ-test/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/SearchCommandIT.java @@ -15,6 +15,7 @@ package com.amazon.opendistroforelasticsearch.sql.ppl; +import org.elasticsearch.client.Request; import org.elasticsearch.client.ResponseException; import org.json.JSONObject; import org.junit.jupiter.api.Test; @@ -49,6 +50,15 @@ public void testSearchCommandWithoutSearchKeyword() throws IOException { executeQueryToString(String.format("source=%s", TEST_INDEX_BANK))); } + @Test + public void testSearchCommandWithSpecialIndexName() throws IOException { + executeRequest(new Request("PUT", "/logs-2021.01.11")); + executeQuery("search source=logs-2021.01.11"); + + executeRequest(new Request("PUT", "/logs-7.10.0-2021.01.11")); + executeQuery("search source=logs-7.10.0-2021.01.11"); + } + @Test public void testSearchCommandWithLogicalExpression() throws IOException { JSONObject result = diff --git a/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java b/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java index 51fbb7bfdb..2854c781e7 100644 --- a/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java +++ b/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java @@ -381,6 +381,7 @@ public void testIdentifierAsIndexNameStartWithDot() { @Test public void testIdentifierAsIndexNameWithDotInTheMiddle() { assertEqual("source=log.2020.10.10", relation("log.2020.10.10")); + assertEqual("source=log-7.10-2020.10.10", relation("log-7.10-2020.10.10")); } @Test From 813bb1583eb9990c5d4a994b7e052285a44d281c Mon Sep 17 00:00:00 2001 From: Dai Date: Mon, 11 Jan 2021 14:57:47 -0800 Subject: [PATCH 3/7] Support wildcard in index name with dots --- ppl/src/main/antlr/OpenDistroPPLLexer.g4 | 2 +- .../sql/ppl/parser/AstBuilderTest.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ppl/src/main/antlr/OpenDistroPPLLexer.g4 b/ppl/src/main/antlr/OpenDistroPPLLexer.g4 index d776bf0681..ad03a832f5 100644 --- a/ppl/src/main/antlr/OpenDistroPPLLexer.g4 +++ b/ppl/src/main/antlr/OpenDistroPPLLexer.g4 @@ -242,7 +242,7 @@ INTEGER_LITERAL: DEC_DIGIT+; DECIMAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+; fragment ID_LITERAL: [@*A-Z]+?[*A-Z_\-0-9]*; -ID_DOT: ID_LITERAL ([\-.][0-9]+)*; +ID_DOT: ID_LITERAL ([\-.][*0-9]+)*; DQUOTA_STRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"'; SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\''; BQUOTA_STRING: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`'; diff --git a/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java b/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java index 2854c781e7..11b035153a 100644 --- a/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java +++ b/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstBuilderTest.java @@ -50,7 +50,6 @@ import com.amazon.opendistroforelasticsearch.sql.ast.Node; import com.amazon.opendistroforelasticsearch.sql.ast.tree.RareTopN.CommandType; -import com.amazon.opendistroforelasticsearch.sql.common.antlr.SyntaxCheckException; import com.amazon.opendistroforelasticsearch.sql.ppl.antlr.PPLSyntaxParser; import org.junit.Ignore; import org.junit.Rule; @@ -396,6 +395,13 @@ public void testIdentifierAsIndexNameContainStar() { relation("log-2020-10-*")); } + @Test + public void testIdentifierAsIndexNameContainStarAndDots() { + assertEqual("source=log-2020.10.*", relation("log-2020.10.*")); + assertEqual("source=log-2020.*.01", relation("log-2020.*.01")); + assertEqual("source=log-2020.*.*", relation("log-2020.*.*")); + } + @Test public void testIdentifierAsFieldNameStartWithAt() { assertEqual("source=log-2020 | fields @timestamp", From dd8f2a13ca45db44b7afef9ecc43832050eac75e Mon Sep 17 00:00:00 2001 From: Dai Date: Mon, 11 Jan 2021 15:04:22 -0800 Subject: [PATCH 4/7] Update doc with wildcard case --- docs/experiment/ppl/general/identifiers.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/experiment/ppl/general/identifiers.rst b/docs/experiment/ppl/general/identifiers.rst index 60c3997c0e..951accfbb6 100644 --- a/docs/experiment/ppl/general/identifiers.rst +++ b/docs/experiment/ppl/general/identifiers.rst @@ -30,7 +30,7 @@ For Elasticsearch, the following identifiers are supported extensionally: 3. Identifiers with ``-`` in the middle: this is mostly the case for index name with date information. 4. Identifiers with star ``*`` present: this is mostly an index pattern for wildcard match. -Index name with date suffix separated by dash or dots, such as ``cwl-2020.01.11`` or ``logs-7.0-2020.01.11``, is common for those created by Logstash or FileBeat ingestion. So, this kind of identifier used as index name is also supported without the need of being quoted for user convenience. +Index name with date suffix separated by dash or dots, such as ``cwl-2020.01.11`` or ``logs-7.0-2020.01.11``, is common for those created by Logstash or FileBeat ingestion. So, this kind of identifier used as index name is also supported without the need of being quoted for user convenience. In this case, wildcard within date pattern is also allowed to search for data across indices of different date range. For example, you can use ``logs-2020.1*`` to search in indices for October, November and December 2020. Examples -------- From 27ae92107dbce82809c2fa7debbeac7ad29b9088 Mon Sep 17 00:00:00 2001 From: Dai Date: Mon, 11 Jan 2021 15:15:20 -0800 Subject: [PATCH 5/7] Add assertion for IT --- .../opendistroforelasticsearch/sql/ppl/SearchCommandIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integ-test/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/SearchCommandIT.java b/integ-test/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/SearchCommandIT.java index 4b98b42ca1..76c4c26500 100644 --- a/integ-test/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/SearchCommandIT.java +++ b/integ-test/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/SearchCommandIT.java @@ -53,10 +53,10 @@ public void testSearchCommandWithoutSearchKeyword() throws IOException { @Test public void testSearchCommandWithSpecialIndexName() throws IOException { executeRequest(new Request("PUT", "/logs-2021.01.11")); - executeQuery("search source=logs-2021.01.11"); + verifyDataRows(executeQuery("search source=logs-2021.01.11")); executeRequest(new Request("PUT", "/logs-7.10.0-2021.01.11")); - executeQuery("search source=logs-7.10.0-2021.01.11"); + verifyDataRows(executeQuery("search source=logs-7.10.0-2021.01.11")); } @Test From dce9801223c03af5242d7d4e08ba85ad55841322 Mon Sep 17 00:00:00 2001 From: Dai Date: Mon, 11 Jan 2021 15:37:20 -0800 Subject: [PATCH 6/7] Disable nested field in PPL grammar --- ppl/src/main/antlr/OpenDistroPPLLexer.g4 | 3 ++- ppl/src/main/antlr/OpenDistroPPLParser.g4 | 6 ++--- .../sql/ppl/parser/AstExpressionBuilder.java | 24 +++++++------------ .../ppl/parser/AstExpressionBuilderTest.java | 18 ++++++++++++-- .../ppl/utils/PPLQueryDataAnonymizerTest.java | 4 ++-- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/ppl/src/main/antlr/OpenDistroPPLLexer.g4 b/ppl/src/main/antlr/OpenDistroPPLLexer.g4 index ad03a832f5..0869f15911 100644 --- a/ppl/src/main/antlr/OpenDistroPPLLexer.g4 +++ b/ppl/src/main/antlr/OpenDistroPPLLexer.g4 @@ -241,8 +241,9 @@ ID: ID_LITERAL; INTEGER_LITERAL: DEC_DIGIT+; DECIMAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+; +fragment DATE_SUFFIX: ([\-.][*0-9]+)*; fragment ID_LITERAL: [@*A-Z]+?[*A-Z_\-0-9]*; -ID_DOT: ID_LITERAL ([\-.][*0-9]+)*; +ID_DATE_SUFFIX: ID_LITERAL DATE_SUFFIX; DQUOTA_STRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"'; SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\''; BQUOTA_STRING: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`'; diff --git a/ppl/src/main/antlr/OpenDistroPPLParser.g4 b/ppl/src/main/antlr/OpenDistroPPLParser.g4 index 80a280e54a..f9f7777197 100644 --- a/ppl/src/main/antlr/OpenDistroPPLParser.g4 +++ b/ppl/src/main/antlr/OpenDistroPPLParser.g4 @@ -178,7 +178,7 @@ booleanExpression /** tables */ tableSource : qualifiedName - | ID_DOT + | ID_DATE_SUFFIX ; /** fields */ @@ -312,11 +312,11 @@ valueList ; qualifiedName - : ident (DOT ident)* #identsAsQualifiedName + : ident /* (DOT ident)* */ #identsAsQualifiedName ; wcQualifiedName - : wildcard (DOT wildcard)* #identsAsWildcardQualifiedName + : wildcard /*(DOT wildcard)* */ #identsAsWildcardQualifiedName ; ident diff --git a/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilder.java b/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilder.java index d835d0aedb..0cb16a4121 100644 --- a/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilder.java +++ b/ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilder.java @@ -227,8 +227,7 @@ public UnresolvedExpression visitEvalFunctionCall(EvalFunctionCallContext ctx) { @Override public UnresolvedExpression visitTableSource(TableSourceContext ctx) { - return new QualifiedName(Collections.singletonList( - StringUtils.unquoteIdentifier(ctx.getText()))); + return visitIdentifier(ctx); } /** @@ -236,25 +235,13 @@ public UnresolvedExpression visitTableSource(TableSourceContext ctx) { */ @Override public UnresolvedExpression visitIdentsAsQualifiedName(IdentsAsQualifiedNameContext ctx) { - return new QualifiedName( - ctx.ident() - .stream() - .map(ParserRuleContext::getText) - .map(StringUtils::unquoteText) - .collect(Collectors.toList()) - ); + return visitIdentifier(ctx.ident()); } @Override public UnresolvedExpression visitIdentsAsWildcardQualifiedName( IdentsAsWildcardQualifiedNameContext ctx) { - return new QualifiedName( - ctx.wildcard() - .stream() - .map(ParserRuleContext::getText) - .map(StringUtils::unquoteText) - .collect(Collectors.toList()) - ); + return visitIdentifier(ctx.wildcard()); } @Override @@ -283,4 +270,9 @@ public UnresolvedExpression visitBooleanLiteral(BooleanLiteralContext ctx) { return new Literal(Boolean.valueOf(ctx.getText()), DataType.BOOLEAN); } + private UnresolvedExpression visitIdentifier(ParserRuleContext ctx) { + return new QualifiedName(Collections.singletonList( + StringUtils.unquoteIdentifier(ctx.getText()))); + } + } diff --git a/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilderTest.java b/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilderTest.java index a0a754bef8..7f0f3badb2 100644 --- a/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilderTest.java +++ b/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/parser/AstExpressionBuilderTest.java @@ -376,6 +376,7 @@ public void testEvalFuncCallExpr() { )); } + @Ignore("Nested field is not supported in backend yet") @Test public void testNestedFieldName() { assertEqual("source=t | fields field0.field1.field2", @@ -390,6 +391,19 @@ public void testNestedFieldName() { @Test public void testFieldNameWithSpecialChars() { + assertEqual("source=t | fields `field-0`", + projectWithArg( + relation("t"), + defaultFieldsArgs(), + field( + qualifiedName("field-0") + ) + )); + } + + @Ignore("Nested field is not supported in backend yet") + @Test + public void testNestedFieldNameWithSpecialChars() { assertEqual("source=t | fields `field-0`.`field#1`.`field*2`", projectWithArg( relation("t"), @@ -486,9 +500,9 @@ public void testKeywordsAsIdentifiers() { @Test public void canBuildKeywordsAsIdentInQualifiedName() { assertEqual( - "source=test.timestamp | fields timestamp", + "source=test | fields timestamp", projectWithArg( - relation("test.timestamp"), + relation("test"), defaultFieldsArgs(), field("timestamp") ) diff --git a/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/utils/PPLQueryDataAnonymizerTest.java b/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/utils/PPLQueryDataAnonymizerTest.java index 91b14172c6..2221245866 100644 --- a/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/utils/PPLQueryDataAnonymizerTest.java +++ b/ppl/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/utils/PPLQueryDataAnonymizerTest.java @@ -151,8 +151,8 @@ public void testNotExpression() { @Test public void testQualifiedName() { - assertEquals("source=t | fields + field0.field1", - anonymize("source=t | fields field0.field1") + assertEquals("source=t | fields + field0", + anonymize("source=t | fields field0") ); } From 3ef040a5151aa3e8079f98cbc2e26bea971a858e Mon Sep 17 00:00:00 2001 From: Dai Date: Mon, 11 Jan 2021 20:39:06 -0800 Subject: [PATCH 7/7] Remove commented out code --- ppl/src/main/antlr/OpenDistroPPLParser.g4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ppl/src/main/antlr/OpenDistroPPLParser.g4 b/ppl/src/main/antlr/OpenDistroPPLParser.g4 index f9f7777197..b23bcdd062 100644 --- a/ppl/src/main/antlr/OpenDistroPPLParser.g4 +++ b/ppl/src/main/antlr/OpenDistroPPLParser.g4 @@ -312,11 +312,11 @@ valueList ; qualifiedName - : ident /* (DOT ident)* */ #identsAsQualifiedName + : ident #identsAsQualifiedName ; wcQualifiedName - : wildcard /*(DOT wildcard)* */ #identsAsWildcardQualifiedName + : wildcard #identsAsWildcardQualifiedName ; ident