Class ConstantHolder

java.lang.Object
org.apache.drill.exec.store.base.filter.ConstantHolder
All Implemented Interfaces:
Comparable<ConstantHolder>

public class ConstantHolder extends Object implements Comparable<ConstantHolder>
Description of a constant argument of an expression. Each constant is a (type, value) pair.
  • Field Details

  • Constructor Details

  • Method Details

    • bitValue

      public static ConstantHolder bitValue(boolean value)
    • smallIntValue

      public static ConstantHolder smallIntValue(int value)
    • intValue

      public static ConstantHolder intValue(int value)
    • bigIntValue

      public static ConstantHolder bigIntValue(long value)
    • float4Value

      public static ConstantHolder float4Value(float value)
    • float8Value

      public static ConstantHolder float8Value(double value)
    • decimalValue

      public static ConstantHolder decimalValue(BigDecimal value)
    • varcharValue

      public static ConstantHolder varcharValue(String value)
    • convertTo

      public ConstantHolder convertTo(TypeProtos.MinorType toType)
      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

      public ConstantHolder normalize(TypeProtos.MinorType toType)
      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

      public ConstantHolder toInt()
    • toBigInt

      public ConstantHolder toBigInt()
    • toTimestamp

      public ConstantHolder toTimestamp(String tz)
    • toVarChar

      public ConstantHolder 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

      public ConstantHolder toFloat()
    • toDouble

      public ConstantHolder toDouble()
    • toDecimal

      public ConstantHolder toDecimal()
    • conversionError

      public RuntimeException conversionError(TypeProtos.MinorType toType)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(ConstantHolder other)
      Specified by:
      compareTo in interface Comparable<ConstantHolder>