szehon-ho commented on code in PR #59820:
URL: https://github.com/apache/spark/pull/59820#discussion_r4395216031


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/ResolveDefaultColumnsUtil.scala:
##########
@@ -324,15 +324,23 @@ object ResolveDefaultColumns extends QueryErrorsBase
     coerceDefaultValue(analyzed, dataType, statementType, colName, defaultSQL)
   }
 
+  // Literal.sql always escapes strings, independently of the session's parser 
configuration.
+  // Override only that policy so other settings, such as the time zone, 
remain session-dependent.
+  private lazy val existenceDefaultParser = new CatalystSqlParser {
+    override val astBuilder: AstBuilder = new AstBuilder {
+      override protected def escapedStringLiterals: Boolean = false
+    }
+  }
+
   /**
    * Analyze EXISTS_DEFAULT value.  EXISTS_DEFAULT value was created from 
CURRENT_DEFAQULT
    * via [[analyze]] and thus this can skip most of those steps.
    */
   private def analyzeExistenceDefaultValue(field: StructField): Expression = {
     val defaultSQL = 
field.metadata.getString(EXISTS_DEFAULT_COLUMN_METADATA_KEY)
 
-    // Parse the expression.
-    val resolvedExpr = Try(Literal.fromSQL(defaultSQL)) match {
+    val parsedExpr = Try(Literal.fromSQL(defaultSQL, existenceDefaultParser))

Review Comment:
   **[P2] Preserve session parsing for casts containing functions**
   
   With `escapedStringLiterals=true`, an external `EXISTS_DEFAULT` of 
`CAST(concat('a', '\n') AS STRING)` now produces a newline instead of 
preserving backslash-plus-`n`. `Literal.fromSQL` resolves `concat`, so the 
outer cast passes `c.resolved` and bypasses the session-based fallback. The new 
fallback test misses this because it uses bare `concat`. Please restrict the 
canonical fast path to serialized-literal shapes and add coverage for the 
cast-wrapped expression.



-- 
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]

Reply via email to