You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "cloud-fan (via GitHub)" <gi...@apache.org> on 2023/03/08 12:47:49 UTC

[GitHub] [spark] cloud-fan commented on a diff in pull request #40126: [SPARK-40822][SQL] Stable derived column aliases

cloud-fan commented on code in PR #40126:
URL: https://github.com/apache/spark/pull/40126#discussion_r1129378877


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -465,7 +465,23 @@ class Analyzer(override val catalogManager: CatalogManager) extends RuleExecutor
   }
 
   /**
-   * Replaces [[UnresolvedAlias]]s with concrete aliases.
+   * Replaces [[UnresolvedAlias]]s with concrete aliases by applying the following rules:
+   *   1. Use the specified name of named expressions;
+   *   2. Derive stable aliases from the lexer tree of the original SQL text by concatenating of
+   *      terms via a single space, and applying the additional rules:
+   *     2.0. Don't add a space between terms if at least one of them contains a char which is not
+   *          a letter and a digit.
+   *     2.1. Normalize SQL string literals when ANSI mode is enabled and the SQL config
+   *          `spark.sql.ansi.doubleQuotedIdentifiers` is set to `true`.
+   *          For example: "abc" => 'abc'
+   *     2.2. A multipart identifier (column, field, mapkey, ...) -> the right most identifier.
+   *          For example: a.b.c => c
+   *     2.3. A CAST, or try_cast -> the argument of the cast.
+   *          For example: CAST(c1 AS INT) => c1
+   *     2.4. A map lookup with a literal -> the map key.
+   *          For example: map[5] => 5

Review Comment:
   is this really what we want? what was the previous behavior?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org