MaxGekk commented on code in PR #40126:
URL: https://github.com/apache/spark/pull/40126#discussion_r1119866910


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/ResolveAliasesSuite.scala:
##########
@@ -88,4 +94,46 @@ class ResolveAliasesSuite extends AnalysisTest {
     checkAliasName(t1.select(DateSub(Literal(Date.valueOf("2021-01-18")), 
Literal(null))),
       "date_sub(DATE '2021-01-18', NULL)")
   }
+
+  test("SPARK-40822: Stable derived column aliases") {
+    withSQLConf(SQLConf.STABLE_DERIVED_COLUMN_ALIAS_ENABLED.key -> "true") {
+      Seq(
+        // Literals
+        "' 1'" -> "' 1'",
+        """"abc"""" -> """"abc"""",
+        """'\t\n xyz \t\r'""" -> """'\t\n xyz \t\r'""",
+        "1L" -> "1L", "1S" -> "1S",
+        "date'-0001-1-28'" -> "date'-0001-1-28'",
+        "interval 3 year 1 month" -> "interval 3 year 1 month",
+        "x'00'" -> "x'00'",
+        // Preserve case
+        "CAST(1 as tinyint)" -> "CAST(1 as tinyint)",
+        // Brackets
+        "getbit(11L, 2 + 1)" -> "getbit(11L,2+1)",
+        "string(int(shiftleft(int(-1), 31))+1)" -> 
"string(int(shiftleft(int(-1),31))+1)",
+        "map(1, 'a') [ 5 ]" -> "map(1,'a')[5]",
+        // Preserve type
+        "CAST('123.a' AS long)" -> "CAST('123.a'AS long)",
+        // Spaces
+        "'1' = 1" -> "'1'=1",
+        "upper('a') = upper('A')" -> "upper('a')=upper('A')",
+        "FLOOR(5, 0)" -> "FLOOR(5,0)",
+        "-1" -> "-1",
+        "1 in (1.0)" -> "1 in(1.0)",

Review Comment:
   > ditto
   
   This is different case from the previous one. How can I distinguish the two 
cases?
   ```floor(``` and ```in(```



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