Class ConstantHolder
java.lang.Object
org.apache.drill.exec.store.base.filter.ConstantHolder
- All Implemented Interfaces:
Comparable<ConstantHolder>
Description of a constant argument of an expression.
Each constant is a (type, value) pair.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConstantHolderbigIntValue(long value) static ConstantHolderbitValue(boolean value) intcompareTo(ConstantHolder other) conversionError(TypeProtos.MinorType toType) convertTo(TypeProtos.MinorType toType) Convert a constant to the given type.static ConstantHolderdecimalValue(BigDecimal value) static ConstantHolderfloat4Value(float value) static ConstantHolderfloat8Value(double value) static ConstantHolderintValue(int value) normalize(TypeProtos.MinorType toType) Normalize the constant to the given type.static ConstantHoldersmallIntValue(int value) toBigInt()toDouble()toFloat()toInt()toString()toTimestamp(String tz) Convert the value to a String.static ConstantHoldervarcharValue(String value)
-
Field Details
-
type
-
value
-
-
Constructor Details
-
ConstantHolder
-
-
Method Details
-
bitValue
-
smallIntValue
-
intValue
-
bigIntValue
-
float4Value
-
float8Value
-
decimalValue
-
varcharValue
-
convertTo
Convert a constant to the given type. Conversion is defined only for some types (where conversion makes sense) and only for some values (only those that would result in a valid conversion.)- Parameters:
toType- the target type- Returns:
- a constant of the requested type
- Throws:
RuntimeException- if the conversion is not legal
-
normalize
Normalize the constant to the given type. Return null if the constant cannot be converted. Use this test to determine if the constant is of a form that can be pushed down when push-down only supports certain types. In such a case, the query will likely fail at execution time when Drill tries to compare the remaining filter with an incompatible column type.- Parameters:
toType- the target type- Returns:
- a constant of the requested type or null if the conversion is not defined or is not legal for the given value
-
toInt
-
toBigInt
-
toTimestamp
-
toVarChar
Convert the value to a String. Consider this as a debug tool as no attempt is made to format values in any particular way. Date, time, interval and bit values will appear as numbers, which is probably not what most target systems expect.- Returns:
- the value as a string using the
toString()method on the value
-
toFloat
-
toDouble
-
toDecimal
-
conversionError
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<ConstantHolder>
-