2121from py4j .protocol import Py4JError
2222
2323__all__ = [
24- "StringType" , "BinaryType" , "BooleanType" , "DecimalType " , "DoubleType " ,
25- "FloatType " , "ByteType " , "IntegerType " , "LongType " , "ShortType " ,
26- "ArrayType" , "MapType" , "StructField" , "StructType" ,
24+ "StringType" , "BinaryType" , "BooleanType" , "TimestampType " , "DecimalType " ,
25+ "DoubleType " , "FloatType " , "ByteType " , "IntegerType " , "LongType " ,
26+ "ShortType" , " ArrayType" , "MapType" , "StructField" , "StructType" ,
2727 "SQLContext" , "HiveContext" , "LocalHiveContext" , "TestHiveContext" , "SchemaRDD" , "Row" ]
2828
2929class PrimitiveTypeSingleton (type ):
@@ -106,7 +106,7 @@ class FloatType(object):
106106 Because query evaluation is done in Scala, java.lang.Double will be be used
107107 for Python float numbers. Because the underlying JVM type of FloatType is
108108 java.lang.Float (in Java) and Float (in scala), there will be a java.lang.ClassCastException
109- if FloatType (Python) used.
109+ if FloatType (Python) is used.
110110
111111 """
112112 __metaclass__ = PrimitiveTypeSingleton
@@ -121,7 +121,7 @@ class ByteType(object):
121121 Because query evaluation is done in Scala, java.lang.Integer will be be used
122122 for Python int numbers. Because the underlying JVM type of ByteType is
123123 java.lang.Byte (in Java) and Byte (in scala), there will be a java.lang.ClassCastException
124- if ByteType (Python) used.
124+ if ByteType (Python) is used.
125125
126126 """
127127 __metaclass__ = PrimitiveTypeSingleton
@@ -159,7 +159,7 @@ class ShortType(object):
159159 Because query evaluation is done in Scala, java.lang.Integer will be be used
160160 for Python int numbers. Because the underlying JVM type of ShortType is
161161 java.lang.Short (in Java) and Short (in scala), there will be a java.lang.ClassCastException
162- if ShortType (Python) used.
162+ if ShortType (Python) is used.
163163
164164 """
165165 __metaclass__ = PrimitiveTypeSingleton
@@ -171,13 +171,16 @@ class ArrayType(object):
171171 """Spark SQL ArrayType
172172
173173 The data type representing list values.
174+ An ArrayType object comprises two fields, elementType (a DataType) and containsNull (a bool).
175+ The field of elementType is used to specify the type of array elements.
176+ The field of containsNull is used to specify if the array has None values.
174177
175178 """
176179 def __init__ (self , elementType , containsNull = False ):
177180 """Creates an ArrayType
178181
179182 :param elementType: the data type of elements.
180- :param containsNull: indicates whether the list contains null values.
183+ :param containsNull: indicates whether the list contains None values.
181184 :return:
182185
183186 >>> ArrayType(StringType) == ArrayType(StringType, False)
@@ -205,6 +208,12 @@ class MapType(object):
205208 """Spark SQL MapType
206209
207210 The data type representing dict values.
211+ A MapType object comprises three fields,
212+ keyType (a DataType), valueType (a DataType) and valueContainsNull (a bool).
213+ The field of keyType is used to specify the type of keys in the map.
214+ The field of valueType is used to specify the type of values in the map.
215+ The field of valueContainsNull is used to specify if values of this map has None values.
216+ For values of a MapType column, keys are not allowed to have None values.
208217
209218 """
210219 def __init__ (self , keyType , valueType , valueContainsNull = True ):
@@ -241,6 +250,10 @@ class StructField(object):
241250 """Spark SQL StructField
242251
243252 Represents a field in a StructType.
253+ A StructField object comprises three fields, name (a string), dataType (a DataType),
254+ and nullable (a bool). The field of name is the name of a StructField. The field of
255+ dataType specifies the data type of a StructField.
256+ The field of nullable specifies if values of a StructField can contain None values.
244257
245258 """
246259 def __init__ (self , name , dataType , nullable ):
@@ -276,7 +289,8 @@ def __ne__(self, other):
276289class StructType (object ):
277290 """Spark SQL StructType
278291
279- The data type representing tuple values.
292+ The data type representing namedtuple values.
293+ A StructType object comprises a list of L{StructField}s.
280294
281295 """
282296 def __init__ (self , fields ):
@@ -308,6 +322,11 @@ def __ne__(self, other):
308322 return not self .__eq__ (other )
309323
310324def _parse_datatype_list (datatype_list_string ):
325+ """Parses a list of comma separated data types.
326+
327+ :param datatype_list_string:
328+ :return:
329+ """
311330 index = 0
312331 datatype_list = []
313332 start = 0
@@ -331,6 +350,7 @@ def _parse_datatype_list(datatype_list_string):
331350
332351def _parse_datatype_string (datatype_string ):
333352 """Parses the given data type string.
353+
334354 :param datatype_string:
335355 :return:
336356
0 commit comments