Class TypeInferenceUtils
java.lang.Object
org.apache.drill.exec.planner.sql.TypeInferenceUtils
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic FunctionCall
convertSqlOperatorBindingToFunctionCall
(org.apache.calcite.sql.SqlOperatorBinding opBinding) Given a SqlOperatorBinding, convert it to FunctionCallstatic 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.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 aSqlTypeName
and nullability, create a RelDataType from the RelDataTypeFactorystatic org.apache.calcite.sql.type.SqlTypeName
Given a Drill's TypeProtos.MinorType, return a Calcite's corresponding SqlTypeNamestatic TypeProtos.MajorType
getDrillMajorTypeFromCalciteType
(org.apache.calcite.rel.type.RelDataType relDataType) ReturnsTypeProtos.MajorType
instance which corresponds to specifiedRelDataType relDataType
with its nullability, scale and precision if it is available.static org.apache.calcite.sql.type.SqlReturnTypeInference
getDrillSqlReturnTypeInference
(String name, List<DrillFuncHolder> functions) Give the name and DrillFuncHolder list, return the inference mechanism.static TypeProtos.MinorType
getDrillTypeFromCalciteType
(org.apache.calcite.rel.type.RelDataType relDataType) Given a Calcite's RelDataType, return a Drill's corresponding TypeProtos.MinorTypestatic TypeProtos.MinorType
getDrillTypeFromCalciteType
(org.apache.calcite.sql.type.SqlTypeName sqlTypeName) Given a Calcite's SqlTypeName, return a Drill's corresponding TypeProtos.MinorTypestatic org.apache.calcite.sql.type.SqlTypeName
getSqlTypeNameForTimeUnit
(String timeUnitStr) For Extract and date_part functions, infer the return types based on timeUnitstatic boolean
isScalarStringType
(org.apache.calcite.sql.type.SqlTypeName sqlTypeName) Checks if given type is string scalar type.
-
Field Details
-
UNKNOWN_TYPE
-
-
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) ReturnsTypeProtos.MajorType
instance which corresponds to specifiedRelDataType 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
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 aSqlTypeName
and nullability, create a RelDataType from the RelDataTypeFactory- Parameters:
typeFactory
- RelDataTypeFactory used to create the RelDataTypesqlTypeName
- the given SqlTypeNameisNullable
- 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 RelDataTypedrillType
- the given TypeProtos.MajorTypeisNullable
- 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
-