Class TypeInferenceUtils

java.lang.Object
org.apache.drill.exec.planner.sql.TypeInferenceUtils

public class TypeInferenceUtils extends Object
  • Field Details

  • Method Details

    • getCalciteTypeFromDrillType

      public static org.apache.calcite.sql.type.SqlTypeName getCalciteTypeFromDrillType(TypeProtos.MinorType type)
      Given a Drill's TypeProtos.MinorType, return a Calcite's corresponding SqlTypeName
    • getDrillTypeFromCalciteType

      public static TypeProtos.MinorType getDrillTypeFromCalciteType(org.apache.calcite.rel.type.RelDataType relDataType)
      Given a Calcite's RelDataType, return a Drill's corresponding TypeProtos.MinorType
    • getDrillMajorTypeFromCalciteType

      public static TypeProtos.MajorType getDrillMajorTypeFromCalciteType(org.apache.calcite.rel.type.RelDataType relDataType)
      Returns TypeProtos.MajorType instance which corresponds to specified RelDataType relDataType with its nullability, scale and precision if it is available.
      Parameters:
      relDataType - RelDataType to convert
      Returns:
      TypeProtos.MajorType instance
    • getDrillTypeFromCalciteType

      public static TypeProtos.MinorType getDrillTypeFromCalciteType(org.apache.calcite.sql.type.SqlTypeName sqlTypeName)
      Given a Calcite's SqlTypeName, return a Drill's corresponding TypeProtos.MinorType
    • getDrillSqlReturnTypeInference

      public static org.apache.calcite.sql.type.SqlReturnTypeInference getDrillSqlReturnTypeInference(String name, List<DrillFuncHolder> functions)
      Give the name and DrillFuncHolder list, return the inference mechanism.
    • isScalarStringType

      public static boolean isScalarStringType(org.apache.calcite.sql.type.SqlTypeName sqlTypeName)
      Checks if given type is string scalar type.
      Parameters:
      sqlTypeName - Calcite's sql type name
      Returns:
      true if given type is string scalar type
    • getSqlTypeNameForTimeUnit

      public static org.apache.calcite.sql.type.SqlTypeName getSqlTypeNameForTimeUnit(String timeUnitStr)
      For Extract and date_part functions, infer the return types based on timeUnit
    • createCalciteTypeWithNullability

      public static org.apache.calcite.rel.type.RelDataType createCalciteTypeWithNullability(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory, org.apache.calcite.sql.type.SqlTypeName sqlTypeName, boolean isNullable)
      Given a SqlTypeName and nullability, create a RelDataType from the RelDataTypeFactory
      Parameters:
      typeFactory - RelDataTypeFactory used to create the RelDataType
      sqlTypeName - the given SqlTypeName
      isNullable - the nullability of the created RelDataType
      Returns:
      RelDataType Type of call
    • convertToCalciteType

      public static org.apache.calcite.rel.type.RelDataType convertToCalciteType(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory, TypeProtos.MajorType drillType, boolean isNullable)
      Creates a RelDataType using specified RelDataTypeFactory which corresponds to specified TypeProtos.MajorType.
      Parameters:
      typeFactory - RelDataTypeFactory used to create the RelDataType
      drillType - the given TypeProtos.MajorType
      isNullable - nullability of the resulting type
      Returns:
      RelDataType which corresponds to specified TypeProtos.MajorType
    • convertSqlOperatorBindingToFunctionCall

      public static FunctionCall convertSqlOperatorBindingToFunctionCall(org.apache.calcite.sql.SqlOperatorBinding opBinding)
      Given a SqlOperatorBinding, convert it to FunctionCall
      Parameters:
      opBinding - the given SqlOperatorBinding
      Returns:
      FunctionCall the converted FunctionCall