You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "zhengruifeng (via GitHub)" <gi...@apache.org> on 2023/10/04 08:04:27 UTC

Re: [PR] [SPARK-45088][PYTHON][CONNECT] Make `getitem` work with duplicated columns [spark]

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


##########
python/pyspark/sql/tests/test_dataframe.py:
##########
@@ -63,6 +62,51 @@
 
 
 class DataFrameTestsMixin:
+    def test_getitem_invalid_indices(self):
+        df = self.spark.sql(
+            "SELECT * FROM VALUES "
+            "(1, 1.1, 'a'), "
+            "(2, 2.2, 'b'), "
+            "(4, 4.4, 'c') "
+            "AS TAB(a, b, c)"
+        )
+
+        # accepted type and values
+        for index in [False, True, 0, 1, 2, -1, -2, -3]:
+            df[index]

Review Comment:
   ```
   scala> val df = Seq((2, 1), (1, 2)).toDF("a", "b")
   val df: org.apache.spark.sql.DataFrame = [a: int, b: int]
   
   scala> df.show()
   +---+---+
   |  a|  b|
   +---+---+
   |  2|  1|
   |  1|  2|
   +---+---+
   
   
   scala> df.orderBy(lit(1)).show()
   +---+---+
   |  a|  b|
   +---+---+
   |  1|  2|
   |  2|  1|
   +---+---+
   
   
   scala> df.groupBy(lit(1)).agg(first(col("a")), max(col("b"))).show()
   +---+--------+------+
   |  1|first(a)|max(b)|
   +---+--------+------+
   |  1|       2|     2|
   +---+--------+------+
   ```
   
   it seems `orderBy(lit(1))` directly works, while `groupBy(lit(1))` needs some investigation.
   
   Let me revert this PR first



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