@PublicEvolving public final class DecimalType extends LogicalType
The serialized string representation is DECIMAL(p, s)
where p
is the number of
digits in a number (=precision) and s
is the number of digits to the right of the decimal
point in a number (=scale). p
must have a value between 1 and 38 (both inclusive). s
must have a value between 0 and p
(both inclusive). The default value for p
is
10. The default value for s
is 0. NUMERIC(p, s)
and DEC(p, s)
are
synonyms for this type.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PRECISION |
static int |
DEFAULT_SCALE |
static int |
MAX_PRECISION |
static int |
MIN_PRECISION |
static int |
MIN_SCALE |
Constructor and Description |
---|
DecimalType() |
DecimalType(boolean isNullable,
int precision,
int scale) |
DecimalType(int precision) |
DecimalType(int precision,
int scale) |
Modifier and Type | Method and Description |
---|---|
<R> R |
accept(LogicalTypeVisitor<R> visitor) |
String |
asSerializableString()
Returns a string that fully serializes this instance.
|
LogicalType |
copy(boolean isNullable)
Returns a deep copy of this type with possibly different nullability.
|
boolean |
equals(Object o) |
List<LogicalType> |
getChildren() |
Class<?> |
getDefaultConversion()
Returns the default conversion class.
|
int |
getPrecision() |
int |
getScale() |
int |
hashCode() |
boolean |
supportsInputConversion(Class<?> clazz)
Returns whether an instance of the given class can be represented as a value of this logical
type when entering the table ecosystem.
|
boolean |
supportsOutputConversion(Class<?> clazz)
Returns whether a value of this logical type can be represented as an instance of the given
class when leaving the table ecosystem.
|
asSummaryString, conversionSet, copy, getTypeRoot, is, is, isAnyOf, isAnyOf, isNullable, toString, withNullability
public static final int MIN_PRECISION
public static final int MAX_PRECISION
public static final int DEFAULT_PRECISION
public static final int MIN_SCALE
public static final int DEFAULT_SCALE
public DecimalType(boolean isNullable, int precision, int scale)
public DecimalType(int precision, int scale)
public DecimalType(int precision)
public DecimalType()
public int getPrecision()
public int getScale()
public LogicalType copy(boolean isNullable)
LogicalType
copy
in class LogicalType
isNullable
- the intended nullability of the copied typepublic String asSerializableString()
LogicalType
See LogicalTypeParser
for the reverse operation.
asSerializableString
in class LogicalType
public boolean supportsInputConversion(Class<?> clazz)
LogicalType
A supported conversion directly maps an input class to a logical type without loss of precision or type widening.
For example, java.lang.Long
or long
can be used as input for BIGINT
independent of the set nullability.
supportsInputConversion
in class LogicalType
clazz
- input class to be converted into this logical typeLogicalType.getDefaultConversion()
public boolean supportsOutputConversion(Class<?> clazz)
LogicalType
A supported conversion directly maps a logical type to an output class without loss of precision or type widening.
For example, java.lang.Long
or long
can be used as output for BIGINT
if the type is not nullable. If the type is nullable, only java.lang.Long
can
represent this.
supportsOutputConversion
in class LogicalType
clazz
- output class to be converted from this logical typeLogicalType.getDefaultConversion()
public Class<?> getDefaultConversion()
LogicalType
For example, java.lang.Long
is the default input and output for BIGINT
.
getDefaultConversion
in class LogicalType
LogicalType.supportsInputConversion(Class)
,
LogicalType.supportsOutputConversion(Class)
public List<LogicalType> getChildren()
getChildren
in class LogicalType
public <R> R accept(LogicalTypeVisitor<R> visitor)
accept
in class LogicalType
public boolean equals(Object o)
equals
in class LogicalType
public int hashCode()
hashCode
in class LogicalType
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.