Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18926#discussion_r133116060
  
    --- Diff: python/pyspark/sql/tests.py ---
    @@ -1220,6 +1220,13 @@ def test_rand_functions(self):
             rndn2 = df.select('key', functions.randn(0)).collect()
             self.assertEqual(sorted(rndn1), sorted(rndn2))
     
    +    def test_string_functions(self):
    +        from pyspark.sql.functions import col, lit
    +        df = self.spark.createDataFrame([['nick']], schema=['name'])
    +        self.assertRaises(TypeError, lambda: 
df.select(col('name').substr(0, lit(1))))
    --- End diff --
    
    How about something like this below as this PR targets the exception 
message?
    
    ```python
    startPos = 0
    length = lit(1)
    self.assertRaisesRegexp(
        TypeError,
        "must be the same type.*%s.*%s.*" % (type(startPos), type(length)),
        lambda: df.select(col('name').substr(startPos, length)))
    ```


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

Reply via email to