spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ueshin <...@git.apache.org>
Subject [GitHub] spark pull request #19792: [SPARK-22566][PYTHON] Better error message for `_...
Date Mon, 27 Nov 2017 06:13:22 GMT
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19792#discussion_r153110594
  
    --- Diff: python/pyspark/sql/tests.py ---
    @@ -1722,6 +1723,83 @@ def test_infer_long_type(self):
             self.assertEqual(_infer_type(2**61), LongType())
             self.assertEqual(_infer_type(2**71), LongType())
     
    +    def test_merge_type(self):
    +        self.assertEqual(_merge_type(LongType(), NullType()), LongType())
    +        self.assertEqual(_merge_type(NullType(), LongType()), LongType())
    +
    +        self.assertEqual(_merge_type(LongType(), LongType()), LongType())
    +
    +        self.assertEqual(_merge_type(
    +            ArrayType(LongType()),
    +            ArrayType(LongType())
    +        ), ArrayType(LongType()))
    +        with self.assertRaisesRegexp(TypeError, 'arrayElement'):
    +            _merge_type(ArrayType(LongType()), ArrayType(DoubleType()))
    +
    +        self.assertEqual(_merge_type(
    +            MapType(StringType(), LongType()),
    +            MapType(StringType(), LongType())
    +        ), MapType(StringType(), LongType()))
    +        with self.assertRaisesRegexp(TypeError, 'mapKey'):
    +            _merge_type(
    +                MapType(StringType(), LongType()),
    +                MapType(DoubleType(), LongType()))
    +        with self.assertRaisesRegexp(TypeError, 'mapValue'):
    +            _merge_type(
    +                MapType(StringType(), LongType()),
    +                MapType(StringType(), DoubleType()))
    +
    +        self.assertEqual(_merge_type(
    +            StructType([StructField("f1", LongType()), StructField("f2", StringType())]),
    +            StructType([StructField("f1", LongType()), StructField("f2", StringType())])
    +        ), StructType([StructField("f1", LongType()), StructField("f2", StringType())]))
    +        with self.assertRaisesRegexp(TypeError, r'structField\("f1"\)'):
    --- End diff --
    
    nit: We don't need `r` prefix for each regex for `assertRaisesRegexp`.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message