spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject spark git commit: [SPARK-7978] [SQL] [PYSPARK] DecimalType should not be singleton
Date Mon, 01 Jun 2015 02:56:05 GMT
Repository: spark
Updated Branches:
  refs/heads/branch-1.4 df0bf71ee -> 78a6723e8


[SPARK-7978] [SQL] [PYSPARK] DecimalType should not be singleton

Author: Davies Liu <davies@databricks.com>

Closes #6532 from davies/decimal and squashes the following commits:

c7fcbce [Davies Liu] Update tests.py
1425359 [Davies Liu] DecimalType should not be singleton

(cherry picked from commit 91777a1c3ad3b3ec7b65d5a0413209a9baf6b36a)
Signed-off-by: Reynold Xin <rxin@databricks.com>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/78a6723e
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/78a6723e
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/78a6723e

Branch: refs/heads/branch-1.4
Commit: 78a6723e8758b429f877166973cc4f1bbfce73c4
Parents: df0bf71
Author: Davies Liu <davies@databricks.com>
Authored: Sun May 31 19:55:57 2015 -0700
Committer: Reynold Xin <rxin@databricks.com>
Committed: Sun May 31 19:56:03 2015 -0700

----------------------------------------------------------------------
 python/pyspark/sql/_types.py | 18 ++++++++++++++++--
 python/pyspark/sql/tests.py  |  9 +++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/78a6723e/python/pyspark/sql/_types.py
----------------------------------------------------------------------
diff --git a/python/pyspark/sql/_types.py b/python/pyspark/sql/_types.py
index 9e7e9f0..b6ec613 100644
--- a/python/pyspark/sql/_types.py
+++ b/python/pyspark/sql/_types.py
@@ -97,8 +97,6 @@ class AtomicType(DataType):
     """An internal type used to represent everything that is not
     null, UDTs, arrays, structs, and maps."""
 
-    __metaclass__ = DataTypeSingleton
-
 
 class NumericType(AtomicType):
     """Numeric data types.
@@ -109,6 +107,8 @@ class IntegralType(NumericType):
     """Integral data types.
     """
 
+    __metaclass__ = DataTypeSingleton
+
 
 class FractionalType(NumericType):
     """Fractional data types.
@@ -119,26 +119,36 @@ class StringType(AtomicType):
     """String data type.
     """
 
+    __metaclass__ = DataTypeSingleton
+
 
 class BinaryType(AtomicType):
     """Binary (byte array) data type.
     """
 
+    __metaclass__ = DataTypeSingleton
+
 
 class BooleanType(AtomicType):
     """Boolean data type.
     """
 
+    __metaclass__ = DataTypeSingleton
+
 
 class DateType(AtomicType):
     """Date (datetime.date) data type.
     """
 
+    __metaclass__ = DataTypeSingleton
+
 
 class TimestampType(AtomicType):
     """Timestamp (datetime.datetime) data type.
     """
 
+    __metaclass__ = DataTypeSingleton
+
 
 class DecimalType(FractionalType):
     """Decimal (decimal.Decimal) data type.
@@ -172,11 +182,15 @@ class DoubleType(FractionalType):
     """Double data type, representing double precision floats.
     """
 
+    __metaclass__ = DataTypeSingleton
+
 
 class FloatType(FractionalType):
     """Float data type, representing single precision floats.
     """
 
+    __metaclass__ = DataTypeSingleton
+
 
 class ByteType(IntegralType):
     """Byte data type, i.e. a signed integer in a single byte.

http://git-wip-us.apache.org/repos/asf/spark/blob/78a6723e/python/pyspark/sql/tests.py
----------------------------------------------------------------------
diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py
index 5c53c3a..76384d3 100644
--- a/python/pyspark/sql/tests.py
+++ b/python/pyspark/sql/tests.py
@@ -100,6 +100,15 @@ class DataTypeTests(unittest.TestCase):
         lt2 = pickle.loads(pickle.dumps(LongType()))
         self.assertEquals(lt, lt2)
 
+    # regression test for SPARK-7978
+    def test_decimal_type(self):
+        t1 = DecimalType()
+        t2 = DecimalType(10, 2)
+        self.assertTrue(t2 is not t1)
+        self.assertNotEqual(t1, t2)
+        t3 = DecimalType(8)
+        self.assertNotEqual(t2, t3)
+
 
 class SQLTests(ReusedPySparkTestCase):
 


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


Mime
View raw message