This is an automated email from the ASF dual-hosted git repository.

maxgekk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 2a4d8a4ea70 [SPARK-39243][SQL][DOCS] Rules of quoting elements in 
error messages
2a4d8a4ea70 is described below

commit 2a4d8a4ea709339175257027e31a75bdeed5daec
Author: Max Gekk <max.g...@gmail.com>
AuthorDate: Sun May 22 18:58:25 2022 +0300

    [SPARK-39243][SQL][DOCS] Rules of quoting elements in error messages
    
    ### What changes were proposed in this pull request?
    In the PR, I propose to describe the rules of quoting elements in error 
messages introduced by the PRs:
    - https://github.com/apache/spark/pull/36210
    - https://github.com/apache/spark/pull/36233
    - https://github.com/apache/spark/pull/36259
    - https://github.com/apache/spark/pull/36324
    - https://github.com/apache/spark/pull/36335
    - https://github.com/apache/spark/pull/36359
    - https://github.com/apache/spark/pull/36579
    
    ### Why are the changes needed?
    To improve code maintenance, and the process of code review.
    
    ### Does this PR introduce _any_ user-facing change?
    No.
    
    ### How was this patch tested?
    By existing GAs.
    
    Closes #36621 from MaxGekk/update-error-class-guide.
    
    Authored-by: Max Gekk <max.g...@gmail.com>
    Signed-off-by: Max Gekk <max.g...@gmail.com>
---
 .../org/apache/spark/sql/errors/QueryErrorsBase.scala   | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryErrorsBase.scala 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryErrorsBase.scala
index ab1f8c57480..81c4d0ac408 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryErrorsBase.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryErrorsBase.scala
@@ -23,6 +23,23 @@ import org.apache.spark.sql.catalyst.expressions.Literal
 import org.apache.spark.sql.catalyst.util.quoteIdentifier
 import org.apache.spark.sql.types.{DataType, DoubleType, FloatType}
 
+/**
+ * The trait exposes util methods for preparing error messages such as quoting 
of error elements.
+ * All classes that extent `QueryErrorsBase` shall follow the rules:
+ * 1. Any values shall be outputted in the SQL standard style by using 
`toSQLValue()`.
+ *   For example: 'a string value', 1, NULL.
+ * 2. SQL types shall be double quoted and outputted in the upper case using 
`toSQLType()`.
+ *   For example: "INT", "DECIMAL(10,0)".
+ * 3. Elements of identifiers shall be wrapped by backticks by using 
`toSQLId()`.
+ *   For example: `namespaceA`.`funcB`, `tableC`.
+ * 4. SQL statements shall be in the upper case prepared by using `toSQLStmt`.
+ *   For example: DESC PARTITION, DROP TEMPORARY FUNCTION.
+ * 5. SQL configs and datasource options shall be wrapped by double quotes by 
using
+ *   `toSQLConf()`/`toDSOption()`.
+ *   For example: "spark.sql.ansi.enabled".
+ * 6. Any values of datasource options or SQL configs shall be double quoted.
+ *   For example: "true", "CORRECTED".
+ */
 trait QueryErrorsBase {
   // Converts an error class parameter to its SQL representation
   def toSQLValue(v: Any, t: DataType): String = Literal.create(v, t) match {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to