cloud-fan commented on code in PR #53194: URL: https://github.com/apache/spark/pull/53194#discussion_r2556528333
########## docs/sql-ref-scripting.md: ########## @@ -0,0 +1,89 @@ +--- +layout: global +title: SQL Scripting +displayTitle: SQL Scripting +license: | + 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. +--- + +You can employ powerful procedural logic using SQL/PSM standard-based scripting syntax. +Any SQL script consists of and starts with a [compound statement](control-flow/compound-stmt.html) block (`BEGIN ... END`). +A compound statement starts with a section to declare local variables, user-defined conditions, and condition handlers, which are used to catch exceptions. +This is followed by the compound statement body, which consists of: + +- Flow control statements include loops over predicate expressions, [FOR](control-flow/for-stmt.html) loops over query results, conditional logic such as [IF](control-flow/if-stmt.html) and [CASE](control-flow/case-stmt.html), and means to break out loops such as [LEAVE](control-flow/leave-stmt.html) and [ITERATE](control-flow/iterate-stmt.html). +- DDL statements such as `ALTER`, `CREATE`, `DROP`. +- DML statements [INSERT](sql-ref-syntax-dml-insert-into.html). +- [Queries](sql-ref-syntax-qry-select.html) that return result sets to the invoker of the script. +- [SET](sql-ref-syntax-aux-set-var.html) statements to set local variables as well as session variables. +- The [EXECUTE IMMEDIATE](sql-ref-syntax-aux-exec-imm.html) statement. +- Nested compound statements, which provide nested scopes for variables, conditions, and condition handlers. + +## Enablement + +To enable SQL Scripting, set the `spark.sql.scripting.enabled` flag to `true`. Review Comment: There are a lot of progress on SQL scripting in 4.1, and scripting GA can be a nice achievement to put in the 4.1 release notes. I think the feature is production ready now with the document committed (This feature is available in Databricks products for more than 6 months), but I'll leave the decision to the release manager @dongjoon-hyun -- 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]
