Skip to content

Commit

Permalink
Update grammar validation settings (#3165) (#3166)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8b2d01e)

Signed-off-by: Tomoyuki Morita <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent d413e89 commit 547991b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public enum GrammarElement {

// Functions
MAP_FUNCTIONS("Map functions"),
BITWISE_FUNCTIONS("Bitwise functions"),
CSV_FUNCTIONS("CSV functions"),
GENERATOR_FUNCTIONS("Generator functions"),
MISC_FUNCTIONS("Misc functions"),

// UDF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.opensearch.sql.spark.validator;

import static org.opensearch.sql.spark.validator.GrammarElement.ALTER_VIEW;
import static org.opensearch.sql.spark.validator.GrammarElement.BITWISE_FUNCTIONS;
import static org.opensearch.sql.spark.validator.GrammarElement.CLUSTER_BY;
import static org.opensearch.sql.spark.validator.GrammarElement.CREATE_FUNCTION;
import static org.opensearch.sql.spark.validator.GrammarElement.CREATE_VIEW;
Expand Down Expand Up @@ -71,6 +72,7 @@ public class S3GlueGrammarElementValidator extends DenyListGrammarElementValidat
SET,
SHOW_FUNCTIONS,
SHOW_VIEWS,
BITWISE_FUNCTIONS,
MISC_FUNCTIONS,
UDF)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,18 @@ private void validateFunctionAllowed(String function) {
case MAP:
validateAllowed(GrammarElement.MAP_FUNCTIONS);
break;
case BITWISE:
validateAllowed(GrammarElement.BITWISE_FUNCTIONS);
break;
case CSV:
validateAllowed(GrammarElement.CSV_FUNCTIONS);
break;
case MISC:
validateAllowed(GrammarElement.MISC_FUNCTIONS);
break;
case GENERATOR:
validateAllowed(GrammarElement.GENERATOR_FUNCTIONS);
break;
case UDF:
validateAllowed(GrammarElement.UDF);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void testDenyAllValidator() {
v.ok(TestElement.JSON_FUNCTIONS);
v.ok(TestElement.MATHEMATICAL_FUNCTIONS);
v.ok(TestElement.STRING_FUNCTIONS);
v.ok(TestElement.BITWISE_FUNCTIONS);
v.ng(TestElement.BITWISE_FUNCTIONS);
v.ok(TestElement.CONVERSION_FUNCTIONS);
v.ok(TestElement.CONDITIONAL_FUNCTIONS);
v.ok(TestElement.PREDICATE_FUNCTIONS);
Expand All @@ -321,7 +321,7 @@ void testDenyAllValidator() {
v.ok(TestElement.WINDOW_FUNCTIONS);

// Generator Functions
v.ok(TestElement.GENERATOR_FUNCTIONS);
v.ng(TestElement.GENERATOR_FUNCTIONS);

// UDFs
v.ng(TestElement.SCALAR_USER_DEFINED_FUNCTIONS);
Expand Down Expand Up @@ -426,7 +426,7 @@ void testS3glueQueries() {
v.ok(TestElement.JSON_FUNCTIONS);
v.ok(TestElement.MATHEMATICAL_FUNCTIONS);
v.ok(TestElement.STRING_FUNCTIONS);
v.ok(TestElement.BITWISE_FUNCTIONS);
v.ng(TestElement.BITWISE_FUNCTIONS);
v.ok(TestElement.CONVERSION_FUNCTIONS);
v.ok(TestElement.CONDITIONAL_FUNCTIONS);
v.ok(TestElement.PREDICATE_FUNCTIONS);
Expand Down

0 comments on commit 547991b

Please sign in to comment.