Class TruncateUtil
truncate
transformations for various types.
This utility class allows for the logic to be reused in different scenarios where input validation is done at different times either in org.apache.iceberg.transforms.Truncate and within defined SQL functions for different compute engines for usage in SQL.
In general, the inputs to the functions should have already been validated by the calling code, as different classes use truncate with different preprocessing. This generally means that the truncation width is positive and the value to truncate is non-null.
Thus, none of these utility functions validate their input. It is the responsibility of the calling code to validate input.
See also UnicodeUtil.truncateString(CharSequence, int) and BinaryUtil.truncateBinaryUnsafe(ByteBuffer, int)
for similar methods for Strings and
ByteBuffers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte
truncateByte
(int width, byte value) static BigDecimal
truncateDecimal
(BigInteger unscaledWidth, BigDecimal value) static int
truncateInt
(int width, int value) static long
truncateLong
(int width, long value) static short
truncateShort
(int width, short value)
-
Method Details
-
truncateByte
public static byte truncateByte(int width, byte value) -
truncateShort
public static short truncateShort(int width, short value) -
truncateInt
public static int truncateInt(int width, int value) -
truncateLong
public static long truncateLong(int width, long value) -
truncateDecimal
-