Package com.databricks.jdbc.common.util
Class DatabricksTypeUtil
- java.lang.Object
-
- com.databricks.jdbc.common.util.DatabricksTypeUtil
-
public class DatabricksTypeUtil extends Object
Utility class for handling various type conversions and mappings between Databricks-specific data types, SQL types, and Arrow types.
-
-
Field Summary
Fields Modifier and Type Field Description static StringARRAYstatic StringBIGINTstatic StringBINARYstatic StringBOOLEANstatic StringBYTEstatic StringCHARstatic StringDATEstatic StringDECIMALstatic StringDOUBLEstatic StringFLOATstatic StringGEOGRAPHYstatic StringGEOGRAPHY_CLASS_NAMEstatic StringGEOMETRYstatic StringGEOMETRY_CLASS_NAMEstatic StringINTstatic StringINTERVALstatic StringLONGstatic StringMAPstatic StringMEASUREstatic StringNULLstatic StringSMALLINTstatic StringSTRINGstatic StringSTRUCTstatic StringTIMEstatic StringTIMESTAMPstatic StringTIMESTAMP_NTZstatic StringTINYINTstatic StringVARIANTstatic StringVOID
-
Constructor Summary
Constructors Constructor Description DatabricksTypeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int[]getBasePrecisionAndScale(int columnType, IDatabricksConnectionContext ctx)static ColumnInfoTypeNamegetColumnInfoType(String typeName)static intgetColumnType(ColumnInfoTypeName typeName)static StringgetColumnTypeClassName(ColumnInfoTypeName typeName)static StringgetDatabricksTypeFromSQLType(int sqlType)Converts SQL type into Databricks type as defined herestatic StringgetDecimalTypeString(BigDecimal bd)static intgetDisplaySize(int sqlType, int precision)Returns the display size for a given SQL type and precision.static intgetDisplaySize(ColumnInfoTypeName typeName, int precision, int scale)static intgetMetadataColPrecision(Integer columnType)static NullablegetNullableFromValue(Integer isNullable)static intgetPrecision(Integer columnType)static intgetScale(Integer columnType)static TPrimitiveTypeEntrygetTPrimitiveTypeOrDefault(TTypeDesc typeDesc)static StringinferDatabricksType(Object obj)Infers Databricks type from class of given object as defined in herestatic booleanisSigned(ColumnInfoTypeName typeName)static org.apache.arrow.vector.types.pojo.ArrowTypemapThriftToArrowType(TTypeId typeId)
-
-
-
Field Detail
-
BIGINT
public static final String BIGINT
- See Also:
- Constant Field Values
-
LONG
public static final String LONG
- See Also:
- Constant Field Values
-
BINARY
public static final String BINARY
- See Also:
- Constant Field Values
-
BOOLEAN
public static final String BOOLEAN
- See Also:
- Constant Field Values
-
DATE
public static final String DATE
- See Also:
- Constant Field Values
-
DECIMAL
public static final String DECIMAL
- See Also:
- Constant Field Values
-
DOUBLE
public static final String DOUBLE
- See Also:
- Constant Field Values
-
FLOAT
public static final String FLOAT
- See Also:
- Constant Field Values
-
INT
public static final String INT
- See Also:
- Constant Field Values
-
BYTE
public static final String BYTE
- See Also:
- Constant Field Values
-
VOID
public static final String VOID
- See Also:
- Constant Field Values
-
SMALLINT
public static final String SMALLINT
- See Also:
- Constant Field Values
-
NULL
public static final String NULL
- See Also:
- Constant Field Values
-
STRING
public static final String STRING
- See Also:
- Constant Field Values
-
TINYINT
public static final String TINYINT
- See Also:
- Constant Field Values
-
TIMESTAMP
public static final String TIMESTAMP
- See Also:
- Constant Field Values
-
TIME
public static final String TIME
- See Also:
- Constant Field Values
-
TIMESTAMP_NTZ
public static final String TIMESTAMP_NTZ
- See Also:
- Constant Field Values
-
MAP
public static final String MAP
- See Also:
- Constant Field Values
-
ARRAY
public static final String ARRAY
- See Also:
- Constant Field Values
-
STRUCT
public static final String STRUCT
- See Also:
- Constant Field Values
-
VARIANT
public static final String VARIANT
- See Also:
- Constant Field Values
-
CHAR
public static final String CHAR
- See Also:
- Constant Field Values
-
INTERVAL
public static final String INTERVAL
- See Also:
- Constant Field Values
-
GEOMETRY
public static final String GEOMETRY
- See Also:
- Constant Field Values
-
GEOGRAPHY
public static final String GEOGRAPHY
- See Also:
- Constant Field Values
-
GEOMETRY_CLASS_NAME
public static final String GEOMETRY_CLASS_NAME
- See Also:
- Constant Field Values
-
GEOGRAPHY_CLASS_NAME
public static final String GEOGRAPHY_CLASS_NAME
- See Also:
- Constant Field Values
-
MEASURE
public static final String MEASURE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getColumnInfoType
public static ColumnInfoTypeName getColumnInfoType(String typeName)
-
getColumnType
public static int getColumnType(ColumnInfoTypeName typeName)
-
getColumnTypeClassName
public static String getColumnTypeClassName(ColumnInfoTypeName typeName)
-
getBasePrecisionAndScale
public static int[] getBasePrecisionAndScale(int columnType, IDatabricksConnectionContext ctx)
-
getDisplaySize
public static int getDisplaySize(ColumnInfoTypeName typeName, int precision, int scale)
-
getDisplaySize
public static int getDisplaySize(int sqlType, int precision)Returns the display size for a given SQL type and precision. This method is used only in pre-defined result set metadata flow.- Parameters:
sqlType- the SQL type as defined inTypesprecision- the precision of the column- Returns:
- the display size for the given SQL type and precision
-
getMetadataColPrecision
public static int getMetadataColPrecision(Integer columnType)
-
getPrecision
public static int getPrecision(Integer columnType)
-
getScale
public static int getScale(Integer columnType)
-
isSigned
public static boolean isSigned(ColumnInfoTypeName typeName)
-
getDatabricksTypeFromSQLType
public static String getDatabricksTypeFromSQLType(int sqlType)
Converts SQL type into Databricks type as defined here- Parameters:
sqlType- SQL type input- Returns:
- databricks type
-
inferDatabricksType
public static String inferDatabricksType(Object obj)
Infers Databricks type from class of given object as defined in here- Parameters:
obj- input object- Returns:
- inferred Databricks type
-
getTPrimitiveTypeOrDefault
public static TPrimitiveTypeEntry getTPrimitiveTypeOrDefault(TTypeDesc typeDesc)
-
mapThriftToArrowType
public static org.apache.arrow.vector.types.pojo.ArrowType mapThriftToArrowType(TTypeId typeId) throws SQLException
- Throws:
SQLException
-
getDecimalTypeString
public static String getDecimalTypeString(BigDecimal bd)
-
-