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 StringDATEstatic StringDECIMALstatic StringDOUBLEstatic StringFLOATstatic StringINTstatic StringMAPstatic StringNULLstatic StringSMALLINTstatic StringSTRINGstatic StringSTRUCTstatic StringTIMEstatic StringTIMESTAMPstatic StringTIMESTAMP_NTZstatic StringTINYINTstatic StringVOID
-
Constructor Summary
Constructors Constructor Description DatabricksTypeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.databricks.sdk.service.sql.ColumnInfoTypeNamegetColumnInfoType(String typeName)static intgetColumnType(com.databricks.sdk.service.sql.ColumnInfoTypeName typeName)static StringgetColumnTypeClassName(com.databricks.sdk.service.sql.ColumnInfoTypeName typeName)static StringgetDatabricksTypeFromSQLType(int sqlType)Converts SQL type into Databricks type as defined herestatic intgetDisplaySize(int sqlType, int precision)Returns the display size for a given SQL type and precision.static intgetDisplaySize(com.databricks.sdk.service.sql.ColumnInfoTypeName typeName, int precision, int scale)static NullablegetNullableFromValue(Integer isNullable)static intgetPrecision(Integer columnType)static intgetScale(Integer columnType)static TTypeIdgetThriftTypeFromTypeDesc(TTypeDesc typeDesc)static StringinferDatabricksType(Object obj)Infers Databricks type from class of given object as defined in herestatic booleanisSigned(com.databricks.sdk.service.sql.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
-
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
-
-
Method Detail
-
getColumnInfoType
public static com.databricks.sdk.service.sql.ColumnInfoTypeName getColumnInfoType(String typeName)
-
getColumnType
public static int getColumnType(com.databricks.sdk.service.sql.ColumnInfoTypeName typeName)
-
getColumnTypeClassName
public static String getColumnTypeClassName(com.databricks.sdk.service.sql.ColumnInfoTypeName typeName)
-
getDisplaySize
public static int getDisplaySize(com.databricks.sdk.service.sql.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
-
getPrecision
public static int getPrecision(Integer columnType)
-
getScale
public static int getScale(Integer columnType)
-
isSigned
public static boolean isSigned(com.databricks.sdk.service.sql.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
-
mapThriftToArrowType
public static org.apache.arrow.vector.types.pojo.ArrowType mapThriftToArrowType(TTypeId typeId) throws SQLException
- Throws:
SQLException
-
-