Skip to content
  • Nicholas Chammas's avatar
    96608310
    [SPARK-21712][PYSPARK] Clarify type error for Column.substr() · 96608310
    Nicholas Chammas authored
    Proposed changes:
    * Clarify the type error that `Column.substr()` gives.
    
    Test plan:
    * Tested this manually.
    * Test code:
        ```python
        from pyspark.sql.functions import col, lit
        spark.createDataFrame([['nick']], schema=['name']).select(col('name').substr(0, lit(1)))
        ```
    * Before:
        ```
        TypeError: Can not mix the type
        ```
    * After:
        ```
        TypeError: startPos and length must be the same type. Got <class 'int'> and
        <class 'pyspark.sql.column.Column'>, respectively.
        ```
    
    Author: Nicholas Chammas <nicholas.chammas@gmail.com>
    
    Closes #18926 from nchammas/SPARK-21712-substr-type-error.
    96608310
    [SPARK-21712][PYSPARK] Clarify type error for Column.substr()
    Nicholas Chammas authored
    Proposed changes:
    * Clarify the type error that `Column.substr()` gives.
    
    Test plan:
    * Tested this manually.
    * Test code:
        ```python
        from pyspark.sql.functions import col, lit
        spark.createDataFrame([['nick']], schema=['name']).select(col('name').substr(0, lit(1)))
        ```
    * Before:
        ```
        TypeError: Can not mix the type
        ```
    * After:
        ```
        TypeError: startPos and length must be the same type. Got <class 'int'> and
        <class 'pyspark.sql.column.Column'>, respectively.
        ```
    
    Author: Nicholas Chammas <nicholas.chammas@gmail.com>
    
    Closes #18926 from nchammas/SPARK-21712-substr-type-error.
Loading