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