Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
DecimalType should not be singleton
  • Loading branch information
Davies Liu committed May 31, 2015
commit 1425359fe2badbec4cccd87d1ce94889ed8eb978
9 changes: 9 additions & 0 deletions python/pyspark/sql/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ def test_data_type_eq(self):
lt2 = pickle.loads(pickle.dumps(LongType()))
self.assertEquals(lt, lt2)

# regression test for SPARK-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant 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):

Expand Down
18 changes: 16 additions & 2 deletions python/pyspark/sql/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -109,6 +107,8 @@ class IntegralType(NumericType):
"""Integral data types.
"""

__metaclass__ = DataTypeSingleton


class FractionalType(NumericType):
"""Fractional data types.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down