You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/11/15 04:54:57 UTC

[GitHub] [spark] zhengruifeng commented on a diff in pull request #38631: [SPARK-40809] [CONNECT] [FOLLOW] Support `alias()` in Python client

zhengruifeng commented on code in PR #38631:
URL: https://github.com/apache/spark/pull/38631#discussion_r1022317152


##########
python/pyspark/sql/tests/connect/test_connect_column_expressions.py:
##########
@@ -134,6 +134,16 @@ def test_list_to_literal(self):
         lit_list_plan = fun.lit([fun.lit(10), fun.lit("str")]).to_plan(None)
         self.assertIsNotNone(lit_list_plan)
 
+    def test_column_alias(self) -> None:
+        # SPARK-40809 - Support for Column Aliases
+        col0 = fun.col("a").alias("martin")
+        self.assertEqual("Alias(Column(a), (martin))", str(col0))
+
+        col0 = fun.col("a").alias("martin", metadata={"pii": True})
+        plan = col0.to_plan(self.session)
+        self.assertIsNotNone(plan)
+        self.assertEqual(plan.alias.metadata, '{"pii": true}')

Review Comment:
   what about also adding a test for `MultiAlias` in python?



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