diff --git a/async-query-core/src/main/java/org/opensearch/sql/spark/validator/GrammarElement.java b/async-query-core/src/main/java/org/opensearch/sql/spark/validator/GrammarElement.java index 0dc0e8944b..ab89348f33 100644 --- a/async-query-core/src/main/java/org/opensearch/sql/spark/validator/GrammarElement.java +++ b/async-query-core/src/main/java/org/opensearch/sql/spark/validator/GrammarElement.java @@ -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 diff --git a/async-query-core/src/main/java/org/opensearch/sql/spark/validator/S3GlueGrammarElementValidator.java b/async-query-core/src/main/java/org/opensearch/sql/spark/validator/S3GlueGrammarElementValidator.java index 9ed1fd9e9e..668ab26d68 100644 --- a/async-query-core/src/main/java/org/opensearch/sql/spark/validator/S3GlueGrammarElementValidator.java +++ b/async-query-core/src/main/java/org/opensearch/sql/spark/validator/S3GlueGrammarElementValidator.java @@ -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; @@ -71,6 +72,7 @@ public class S3GlueGrammarElementValidator extends DenyListGrammarElementValidat SET, SHOW_FUNCTIONS, SHOW_VIEWS, + BITWISE_FUNCTIONS, MISC_FUNCTIONS, UDF) .build(); diff --git a/async-query-core/src/main/java/org/opensearch/sql/spark/validator/SQLQueryValidationVisitor.java b/async-query-core/src/main/java/org/opensearch/sql/spark/validator/SQLQueryValidationVisitor.java index d50503418e..2312c0de7a 100644 --- a/async-query-core/src/main/java/org/opensearch/sql/spark/validator/SQLQueryValidationVisitor.java +++ b/async-query-core/src/main/java/org/opensearch/sql/spark/validator/SQLQueryValidationVisitor.java @@ -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; diff --git a/async-query-core/src/test/java/org/opensearch/sql/spark/validator/SQLQueryValidatorTest.java b/async-query-core/src/test/java/org/opensearch/sql/spark/validator/SQLQueryValidatorTest.java index fbc00109da..520fc96ba8 100644 --- a/async-query-core/src/test/java/org/opensearch/sql/spark/validator/SQLQueryValidatorTest.java +++ b/async-query-core/src/test/java/org/opensearch/sql/spark/validator/SQLQueryValidatorTest.java @@ -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); @@ -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); @@ -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);