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


##########
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:
   
https://github.com/apache/spark/commit/6183b5e2caedd074073d0f6cb6609a634e2f5194
   
   `df[index]` has been supported since spark 2.0.0.
   
   To support `df.groupBy(1, 2, 3)` and `df.orderBy(1, 2, 3)`, right now 
`GetColumnByOrdinal` is only used in the direct child internally.
   
   > The SQL parser also parses ORDER BY 1, 2 as ordering by integer literal 1 
and 2, and analyzer will properly resolve it.
   
   Do you mean use should directly `SortOrder(UnresolvedOrdinal(index))` ?



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