public final class Decimal extends Object implements scala.math.Ordered<Decimal>, scala.Serializable
The semantics of the fields are as follows: - _precision and _scale represent the SQL precision and scale we are looking for - If decimalVal is set, it represents the whole decimal value - Otherwise, the decimal value is longVal / (10 ** _scale)
Note, for values between -1.0 and 1.0, precision digits are only counted after dot.
Modifier and Type | Class and Description |
---|---|
static class |
Decimal.DecimalAsIfIntegral$
A
Integral evidence parameter for Decimals. |
static interface |
Decimal.DecimalIsConflicted
Common methods for Decimal evidence parameters
|
static class |
Decimal.DecimalIsFractional$
A
Fractional evidence parameter for Decimals. |
Constructor and Description |
---|
Decimal() |
Modifier and Type | Method and Description |
---|---|
Decimal |
abs() |
static Decimal |
apply(scala.math.BigDecimal value) |
static Decimal |
apply(java.math.BigDecimal value) |
static Decimal |
apply(scala.math.BigDecimal value,
int precision,
int scale) |
static Decimal |
apply(java.math.BigDecimal value,
int precision,
int scale) |
static Decimal |
apply(scala.math.BigInt value) |
static Decimal |
apply(java.math.BigInteger value) |
static Decimal |
apply(double value) |
static Decimal |
apply(int value) |
static Decimal |
apply(long value) |
static Decimal |
apply(long unscaled,
int precision,
int scale) |
static Decimal |
apply(String value) |
Decimal |
ceil() |
boolean |
changePrecision(int precision,
int scale)
Update precision and scale while keeping our value the same, and return true if successful.
|
Decimal |
clone() |
int |
compare(Decimal other) |
static Decimal |
createUnsafe(long unscaled,
int precision,
int scale)
Creates a decimal from unscaled, precision and scale without checking the bounds.
|
boolean |
equals(Object other) |
Decimal |
floor() |
static Decimal |
fromDecimal(Object value) |
static Decimal |
fromString(org.apache.spark.unsafe.types.UTF8String str) |
static Decimal |
fromStringANSI(org.apache.spark.unsafe.types.UTF8String str,
DecimalType to,
org.apache.spark.sql.catalyst.trees.SQLQueryContext context) |
int |
hashCode() |
boolean |
isZero() |
static int |
MAX_INT_DIGITS()
Maximum number of decimal digits an Int can represent
|
static int |
MAX_LONG_DIGITS()
Maximum number of decimal digits a Long can represent
|
static int |
maxPrecisionForBytes(int numBytes) |
static int[] |
minBytesForPrecision() |
static long[] |
POW_10() |
int |
precision() |
Decimal |
quot(Decimal that) |
Decimal |
remainder(Decimal that) |
static scala.Enumeration.Value |
ROUND_CEILING() |
static scala.Enumeration.Value |
ROUND_FLOOR() |
static scala.Enumeration.Value |
ROUND_HALF_EVEN() |
static scala.Enumeration.Value |
ROUND_HALF_UP() |
int |
scale() |
Decimal |
set(scala.math.BigDecimal decimal)
Set this Decimal to the given BigDecimal value, inheriting its precision and scale.
|
Decimal |
set(scala.math.BigDecimal decimal,
int precision,
int scale)
Set this Decimal to the given BigDecimal value, with a given precision and scale.
|
Decimal |
set(java.math.BigInteger bigintval)
If the value is not in the range of long, convert it to BigDecimal and
the precision and scale are based on the converted value.
|
Decimal |
set(Decimal decimal)
Set this Decimal to the given Decimal value.
|
Decimal |
set(int intVal)
Set this Decimal to the given Int.
|
Decimal |
set(long longVal)
Set this Decimal to the given Long.
|
Decimal |
set(long unscaled,
int precision,
int scale)
Set this Decimal to the given unscaled Long, with a given precision and scale.
|
Decimal |
setOrNull(long unscaled,
int precision,
int scale)
Set this Decimal to the given unscaled Long, with a given precision and scale,
and return it, or return null if it cannot be set due to overflow.
|
scala.math.BigDecimal |
toBigDecimal() |
byte |
toByte() |
String |
toDebugString() |
double |
toDouble() |
float |
toFloat() |
int |
toInt() |
java.math.BigDecimal |
toJavaBigDecimal() |
java.math.BigInteger |
toJavaBigInteger() |
long |
toLong() |
String |
toPlainString() |
scala.math.BigInt |
toScalaBigInt() |
short |
toShort() |
String |
toString() |
long |
toUnscaledLong() |
public static scala.Enumeration.Value ROUND_HALF_UP()
public static scala.Enumeration.Value ROUND_HALF_EVEN()
public static scala.Enumeration.Value ROUND_CEILING()
public static scala.Enumeration.Value ROUND_FLOOR()
public static int MAX_INT_DIGITS()
public static int MAX_LONG_DIGITS()
public static long[] POW_10()
public static Decimal apply(double value)
public static Decimal apply(long value)
public static Decimal apply(int value)
public static Decimal apply(scala.math.BigDecimal value)
public static Decimal apply(java.math.BigDecimal value)
public static Decimal apply(java.math.BigInteger value)
public static Decimal apply(scala.math.BigInt value)
public static Decimal apply(scala.math.BigDecimal value, int precision, int scale)
public static Decimal apply(java.math.BigDecimal value, int precision, int scale)
public static Decimal apply(long unscaled, int precision, int scale)
public static Decimal apply(String value)
public static Decimal fromDecimal(Object value)
public static Decimal fromString(org.apache.spark.unsafe.types.UTF8String str)
public static Decimal fromStringANSI(org.apache.spark.unsafe.types.UTF8String str, DecimalType to, org.apache.spark.sql.catalyst.trees.SQLQueryContext context)
public static Decimal createUnsafe(long unscaled, int precision, int scale)
unscaled
- (undocumented)precision
- (undocumented)scale
- (undocumented)public static int maxPrecisionForBytes(int numBytes)
public static int[] minBytesForPrecision()
public int precision()
public int scale()
public Decimal set(long longVal)
longVal
- (undocumented)public Decimal set(int intVal)
intVal
- (undocumented)public Decimal set(long unscaled, int precision, int scale)
unscaled
- (undocumented)precision
- (undocumented)scale
- (undocumented)public Decimal setOrNull(long unscaled, int precision, int scale)
unscaled
- (undocumented)precision
- (undocumented)scale
- (undocumented)public Decimal set(scala.math.BigDecimal decimal, int precision, int scale)
decimal
- (undocumented)precision
- (undocumented)scale
- (undocumented)public Decimal set(scala.math.BigDecimal decimal)
decimal
- (undocumented)public Decimal set(java.math.BigInteger bigintval)
This code avoids BigDecimal object allocation as possible to improve runtime efficiency
bigintval
- (undocumented)public Decimal set(Decimal decimal)
decimal
- (undocumented)public scala.math.BigDecimal toBigDecimal()
public java.math.BigDecimal toJavaBigDecimal()
public scala.math.BigInt toScalaBigInt()
public java.math.BigInteger toJavaBigInteger()
public long toUnscaledLong()
public String toString()
toString
in class Object
public String toPlainString()
public String toDebugString()
public double toDouble()
public float toFloat()
public long toLong()
public int toInt()
public short toShort()
public byte toByte()
public boolean changePrecision(int precision, int scale)
precision
- (undocumented)scale
- (undocumented)public Decimal clone()
clone
in class Object
public int compare(Decimal other)
compare
in interface scala.math.Ordered<Decimal>
public boolean equals(Object other)
equals
in class Object
public int hashCode()
hashCode
in class Object
public boolean isZero()
public Decimal abs()
public Decimal floor()
public Decimal ceil()