Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/10062#discussion_r46318393
--- Diff: python/pyspark/sql/column.py ---
@@ -183,13 +183,33 @@ def __init__(self, jc):
# container operators
__contains__ = _bin_op("contains")
- __getitem__ = _bin_op("apply")
# bitwise operators
bitwiseOR = _bin_op("bitwiseOR")
bitwiseAND = _bin_op("bitwiseAND")
bitwiseXOR = _bin_op("bitwiseXOR")
+ def __getitem__(self, key):
+ if isinstance(key, slice):
+ if key.step is not None and key.step != 1:
+ raise ValueError("PySpark doesn't support slice with step")
+ if key.start is not None and key.stop is not None:
+ # str[i:j]
+ return self.substr(key.start, key.stop - key.start)
--- End diff --
The start of slice is zero based, but startPos of substr is one based, it's
confusing between these two, so I'd like to not support slice.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]