@@ -683,6 +683,109 @@ void testValidateFlintExtensionQuery_coveringIndexPass() {
683683 DataSourceType .S3GLUE ));
684684 }
685685
686+ @ Test
687+ void testValidateFlintExtensionQuery_blocksMapUsingInMV () {
688+ when (mockedProvider .getValidatorForDatasource (any ()))
689+ .thenReturn (new S3GlueSQLGrammarElementValidator ());
690+ assertThrows (
691+ IllegalArgumentException .class ,
692+ () ->
693+ sqlQueryValidator .validateFlintExtensionQuery (
694+ "CREATE MATERIALIZED VIEW mv AS MAP col USING 'cmd' AS (x) FROM tbl"
695+ + " WITH (auto_refresh = false)" ,
696+ DataSourceType .S3GLUE ));
697+ }
698+
699+ @ Test
700+ void testValidateFlintExtensionQuery_blocksReduceUsingInMV () {
701+ when (mockedProvider .getValidatorForDatasource (any ()))
702+ .thenReturn (new S3GlueSQLGrammarElementValidator ());
703+ assertThrows (
704+ IllegalArgumentException .class ,
705+ () ->
706+ sqlQueryValidator .validateFlintExtensionQuery (
707+ "CREATE MATERIALIZED VIEW mv AS REDUCE col USING 'cmd' AS (x) FROM tbl"
708+ + " WITH (auto_refresh = false)" ,
709+ DataSourceType .S3GLUE ));
710+ }
711+
712+ @ Test
713+ void testValidate_blocksMapUsing () {
714+ when (mockedProvider .getValidatorForDatasource (any ()))
715+ .thenReturn (new S3GlueSQLGrammarElementValidator ());
716+ VerifyValidator v = new VerifyValidator (sqlQueryValidator , DataSourceType .S3GLUE );
717+ v .ng ("MAP col USING 'cmd' AS (x) FROM tbl" );
718+ }
719+
720+ @ Test
721+ void testValidate_blocksReduceUsing () {
722+ when (mockedProvider .getValidatorForDatasource (any ()))
723+ .thenReturn (new S3GlueSQLGrammarElementValidator ());
724+ VerifyValidator v = new VerifyValidator (sqlQueryValidator , DataSourceType .S3GLUE );
725+ v .ng ("REDUCE col USING 'cmd' AS (x) FROM tbl" );
726+ }
727+
728+ @ Test
729+ void testValidateFlintExtensionQuery_blocksReflectInCoveringIndexWhere () {
730+ when (mockedProvider .getValidatorForDatasource (any ()))
731+ .thenReturn (new S3GlueSQLGrammarElementValidator ());
732+ assertThrows (
733+ IllegalArgumentException .class ,
734+ () ->
735+ sqlQueryValidator .validateFlintExtensionQuery (
736+ "CREATE INDEX idx ON tbl (col) WHERE reflect('java.lang.System', 'getenv',"
737+ + " 'PATH') IS NOT NULL" ,
738+ DataSourceType .S3GLUE ));
739+ }
740+
741+ @ Test
742+ void testValidateFlintExtensionQuery_blocksJavaMethodInCoveringIndexWhere () {
743+ when (mockedProvider .getValidatorForDatasource (any ()))
744+ .thenReturn (new S3GlueSQLGrammarElementValidator ());
745+ assertThrows (
746+ IllegalArgumentException .class ,
747+ () ->
748+ sqlQueryValidator .validateFlintExtensionQuery (
749+ "CREATE INDEX idx ON tbl (col) WHERE java_method('java.lang.System', 'getenv',"
750+ + " 'PATH') IS NOT NULL" ,
751+ DataSourceType .S3GLUE ));
752+ }
753+
754+ @ Test
755+ void testValidateFlintExtensionQuery_coveringIndexSafeWherePass () {
756+ when (mockedProvider .getValidatorForDatasource (any ()))
757+ .thenReturn (new S3GlueSQLGrammarElementValidator ());
758+ assertDoesNotThrow (
759+ () ->
760+ sqlQueryValidator .validateFlintExtensionQuery (
761+ "CREATE INDEX idx ON tbl (col) WHERE status > 0 AND age < 100" ,
762+ DataSourceType .S3GLUE ));
763+ }
764+
765+ @ Test
766+ void testValidateFlintExtensionQuery_blocksReflectInSkippingIndexWhere () {
767+ when (mockedProvider .getValidatorForDatasource (any ()))
768+ .thenReturn (new S3GlueSQLGrammarElementValidator ());
769+ assertThrows (
770+ IllegalArgumentException .class ,
771+ () ->
772+ sqlQueryValidator .validateFlintExtensionQuery (
773+ "CREATE SKIPPING INDEX ON tbl (col VALUE_SET) WHERE reflect('java.lang.System',"
774+ + " 'getenv', 'PATH') IS NOT NULL" ,
775+ DataSourceType .S3GLUE ));
776+ }
777+
778+ @ Test
779+ void testValidateFlintExtensionQuery_skippingIndexSafeWherePass () {
780+ when (mockedProvider .getValidatorForDatasource (any ()))
781+ .thenReturn (new S3GlueSQLGrammarElementValidator ());
782+ assertDoesNotThrow (
783+ () ->
784+ sqlQueryValidator .validateFlintExtensionQuery (
785+ "CREATE SKIPPING INDEX ON tbl (col VALUE_SET) WHERE status > 0" ,
786+ DataSourceType .S3GLUE ));
787+ }
788+
686789 @ Test
687790 void testInvalidIdentifier () {
688791 when (mockedProvider .getValidatorForDatasource (any ())).thenReturn (element -> true );
0 commit comments