Skip to content

Commit 753dbe1

Browse files
committed
clarify type error for Column.substr()
1 parent 2387f1e commit 753dbe1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

python/pyspark/sql/column.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,13 @@ def substr(self, startPos, length):
406406
[Row(col=u'Ali'), Row(col=u'Bob')]
407407
"""
408408
if type(startPos) != type(length):
409-
raise TypeError("Can not mix the type")
409+
raise TypeError(
410+
"startPos and length must be the same type. "
411+
"Got {startPos_t} and {length_t}, respectively."
412+
.format(
413+
startPos_t=type(startPos),
414+
length_t=type(length),
415+
))
410416
if isinstance(startPos, (int, long)):
411417
jc = self._jc.substr(startPos, length)
412418
elif isinstance(startPos, Column):

0 commit comments

Comments
 (0)