dtenedor commented on code in PR #46665: URL: https://github.com/apache/spark/pull/46665#discussion_r1612415090
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/SqlScriptingLogicalOperators.scala: ########## @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.catalyst.parser + +import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan + +sealed trait CompoundPlanStatement Review Comment: can we please have a descriptive comment for each of the new traits or classes in this file indicating what they represent and where they are intended to be used. ########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/SqlScriptingLogicalOperators.scala: ########## @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.catalyst.parser + +import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan + +sealed trait CompoundPlanStatement + +// Statement that is supposed to be executed against Spark. +// This can also be a Spark expression that is wrapped in a statement. +case class SparkStatementWithPlan( + parsedPlan: LogicalPlan, + sourceStart: Int, Review Comment: please describe what each of these params represent in the comment? You can use `@param` syntax in the comments for this. ########## sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4: ########## @@ -42,6 +42,29 @@ options { tokenVocab = SqlBaseLexer; } public boolean double_quoted_identifiers = false; } +compoundOrSingleStatement + : singleStatement + | singleCompound + ; + +singleCompound + : compound SEMICOLON* EOF + ; + +compound + : BEGIN compoundBody END + ; + +// Last semicolon in body is optional. +compoundBody Review Comment: is there any value in having this be a separate rule? Can we just list the above as the following instead? ``` : BEGIN compoundStatement (SEMICOLON+ compoundStatement)* SEMICOLON* END ``` ########## sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4: ########## @@ -42,6 +42,29 @@ options { tokenVocab = SqlBaseLexer; } public boolean double_quoted_identifiers = false; } +compoundOrSingleStatement + : singleStatement + | singleCompound + ; + +singleCompound + : compound SEMICOLON* EOF + ; + +compound + : BEGIN compoundBody END + ; + +// Last semicolon in body is optional. +compoundBody + : compoundStatement (SEMICOLON+ compoundStatement)* SEMICOLON* Review Comment: The + after the SEMICOLON represents "one or more semicolons". Is this intended, do we want to allow more than one semicolon in a row with nothing else in between? ########## sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4: ########## @@ -42,6 +42,29 @@ options { tokenVocab = SqlBaseLexer; } public boolean double_quoted_identifiers = false; } +compoundOrSingleStatement + : singleStatement + | singleCompound + ; + +singleCompound + : compound SEMICOLON* EOF + ; + +compound Review Comment: maybe name this something more descriptive like `beginEndBlock` to better indicate its purpose during parsing. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
