# 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 final String`
`ARRAY`
`static final String`
`BIGINT`
`static final String`
`BINARY`
`static final String`
`BOOLEAN`
`static final String`
`BYTE`
`static final String`
`CHAR`
`static final String`
`DATE`
`static final String`
`DECIMAL`
`static final String`
`DOUBLE`
`static final String`
`FLOAT`
`static final String`
`INT`
`static final String`
`INTERVAL`
`static final String`
`LONG`
`static final String`
`MAP`
`static final String`
`MEASURE`
`static final String`
`NULL`
`static final String`
`SMALLINT`
`static final String`
`STRING`
`static final String`
`STRUCT`
`static final String`
`TIME`
`static final String`
`TIMESTAMP`
`static final String`
`TIMESTAMP_NTZ`
`static final String`
`TINYINT`
`static final String`
`VARIANT`
`static final String`
`VOID`

## Constructor Summary

Constructors
Constructor
Description
`DatabricksTypeUtil()`

## Method Summary

Modifier and Type
Method
Description
`static int[]`
`getBasePrecisionAndScale(int columnType, IDatabricksConnectionContext ctx)`
`static ColumnInfoTypeName`
`getColumnInfoType(String typeName)`
`static int`
`getColumnType(ColumnInfoTypeName typeName)`
`static String`
`getColumnTypeClassName(ColumnInfoTypeName typeName)`
`static String`
`getDatabricksTypeFromSQLType(int sqlType)`
Converts SQL type into Databricks type as defined here
`static String`
`getDecimalTypeString(BigDecimal bd)`
`static int`
`getDisplaySize(int sqlType, int precision)`
Returns the display size for a given SQL type and precision.
`static int`
`getDisplaySize(ColumnInfoTypeName typeName, int precision, int scale)`
`static int`
`getMetadataColPrecision(Integer columnType)`
`static Nullable`
`getNullableFromValue(Integer isNullable)`
`static int`
`getPrecision(Integer columnType)`
`static int`
`getScale(Integer columnType)`
`static TPrimitiveTypeEntry`
`getTPrimitiveTypeOrDefault(TTypeDesc typeDesc)`
`static String`
`inferDatabricksType(Object obj)`
Infers Databricks type from class of given object as defined in here
`static boolean`
`isSigned(ColumnInfoTypeName typeName)`
`static org.apache.arrow.vector.types.pojo.ArrowType`
`mapThriftToArrowType(TTypeId typeId)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### 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

### MEASURE

public static final String MEASURE

See Also:
  - Constant Field Values

## Constructor Details

### DatabricksTypeUtil

public DatabricksTypeUtil()

## Method Details

### 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 in `Types`
  `precision` - 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)

### getNullableFromValue

public static Nullable getNullableFromValue(Integer isNullable)

### 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)