Package org.apache.spark.sql.types
Class DecimalType
Object
org.apache.spark.sql.types.DataType
org.apache.spark.sql.types.NumericType
org.apache.spark.sql.types.DecimalType
- All Implemented Interfaces:
Serializable
,scala.Equals
,scala.Product
,scala.Serializable
The data type representing
java.math.BigDecimal
values.
A Decimal that must have fixed precision (the maximum number of digits) and scale (the number
of digits on right side of dot).
The precision can be up to 38, scale can also be up to 38 (less or equal to precision).
The default precision and scale is (10, 0).
Please use DataTypes.createDecimalType()
to create a specific instance.
- Since:
- 1.3.0
- See Also:
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
int
The default size of a value of the DecimalType is 8 bytes when precision is at most 18, and 16 bytes otherwise.static boolean
Returns if dt is a DecimalType that fits inside an intstatic boolean
Returns if dt is a DecimalType that fits inside a longstatic boolean
Returns if dt is a DecimalType that doesn't fit inside a longstatic int
static int
static int
int
int
scale()
sql()
static DecimalType
toString()
typeName()
Name of the type used in JSON serialization.static boolean
static DecimalType
Methods inherited from class org.apache.spark.sql.types.DataType
catalogString, equalsIgnoreCaseAndNullability, equalsIgnoreNullability, equalsStructurally, equalsStructurallyByName, fromDDL, fromJson, json, parseTypeWithFallback, prettyJson, simpleString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface scala.Equals
canEqual, equals
Methods inherited from interface scala.Product
productArity, productElement, productIterator, productPrefix
-
Constructor Details
-
DecimalType
public DecimalType(int precision, int scale) -
DecimalType
public DecimalType(int precision) -
DecimalType
public DecimalType()
-
-
Method Details
-
MAX_PRECISION
public static int MAX_PRECISION() -
MAX_SCALE
public static int MAX_SCALE() -
DEFAULT_SCALE
public static int DEFAULT_SCALE() -
SYSTEM_DEFAULT
-
USER_DEFAULT
-
MINIMUM_ADJUSTED_SCALE
public static int MINIMUM_ADJUSTED_SCALE() -
is32BitDecimalType
Returns if dt is a DecimalType that fits inside an int- Parameters:
dt
- (undocumented)- Returns:
- (undocumented)
-
is64BitDecimalType
Returns if dt is a DecimalType that fits inside a long- Parameters:
dt
- (undocumented)- Returns:
- (undocumented)
-
isByteArrayDecimalType
Returns if dt is a DecimalType that doesn't fit inside a long- Parameters:
dt
- (undocumented)- Returns:
- (undocumented)
-
unapply
-
precision
public int precision() -
scale
public int scale() -
typeName
Description copied from class:DataType
Name of the type used in JSON serialization. -
toString
-
sql
-
defaultSize
public int defaultSize()The default size of a value of the DecimalType is 8 bytes when precision is at most 18, and 16 bytes otherwise.- Specified by:
defaultSize
in classDataType
- Returns:
- (undocumented)
-
simpleString
-