Skip to content

Commit

Permalink
clarify type error for Column.substr()
Browse files Browse the repository at this point in the history
  • Loading branch information
nchammas committed Aug 11, 2017
1 parent 2387f1e commit 753dbe1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python/pyspark/sql/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,13 @@ def substr(self, startPos, length):
[Row(col=u'Ali'), Row(col=u'Bob')]
"""
if type(startPos) != type(length):
raise TypeError("Can not mix the type")
raise TypeError(
"startPos and length must be the same type. "
"Got {startPos_t} and {length_t}, respectively."
.format(
startPos_t=type(startPos),
length_t=type(length),
))
if isinstance(startPos, (int, long)):
jc = self._jc.substr(startPos, length)
elif isinstance(startPos, Column):
Expand Down

0 comments on commit 753dbe1

Please sign in to comment.