View a markdown version of this page

Data types and result conversion - Amazon Athena

Data types and result conversion

ODBC 4.x describes result columns using the SQL type vocabulary for the selected engine. The following mappings apply to DuckDB query results with Unicode type reporting disabled.

The following table lists the reported SQL types and the C types selected for SQL_C_DEFAULT.

DuckDB typeReported SQL typeDefault C type
BOOLEANSQL_BITSQL_C_BIT
TINYINT / SMALLINT / INTEGER / BIGINTMatching signed SQL integer typeMatching signed C integer type
UTINYINTSQL_SMALLINTSQL_C_SHORT
USMALLINTSQL_INTEGERSQL_C_SLONG
UINTEGERSQL_BIGINTSQL_C_SBIGINT
UBIGINT / HUGEINT / UHUGEINTSQL_DECIMALSQL_C_NUMERIC
FLOAT / DOUBLESQL_REAL / SQL_DOUBLESQL_C_FLOAT / SQL_C_DOUBLE
DECIMALSQL_DECIMALSQL_C_NUMERIC
DATESQL_TYPE_DATESQL_C_TYPE_DATE
TIME / TIME_NSSQL_TYPE_TIMESQL_C_TYPE_TIME
TIMESTAMP, TIMESTAMP_S, TIMESTAMP_MS, TIMESTAMP_NS, TIMESTAMPTZSQL_TYPE_TIMESTAMPSQL_C_TYPE_TIMESTAMP
BLOB / GEOMETRYSQL_VARBINARYSQL_C_BINARY
VARCHAR / CHARSQL_VARCHAR / SQL_CHARSQL_C_CHAR
UUID / JSON / BIT / BIGNUM / VARINT / INTERVALSQL_VARCHARSQL_C_CHAR
LIST / ARRAY / STRUCT / TUPLE / MAP / UNION / VARIANTSQL_VARCHARSQL_C_CHAR
TIME WITH TIME ZONESQL_VARCHARSQL_C_CHAR

Character and complex columns

Use StringColumnLength, ComplexTypeColumnLength, and BinaryColumnLength to configure reported lengths. Their defaults are 255, 65535, and 32767, respectively.

DuckDB nested values are returned as DuckDB text when read into character buffers. They are not represented as native ODBC array or struct values.

For binary and geometry columns, use SQL_C_BINARY to request bytes. When geometry is supplied as well-known text by a text result fetcher, the driver converts it to well-known binary. Character reads of these converted geometry values return hexadecimal text.

For wide character bindings and reported types, see Unicode type reporting.

Numeric precision and temporal scale

The default decimal precision is 20 for UBIGINT and 39 for HUGEINT and UHUGEINT, with scale 0. Unsigned integer metadata preserves the unsigned attribute even when the reported SQL type is widened.

The default fractional scale is 0 for TIMESTAMP_S, 3 for TIMESTAMP_MS, 6 for TIME, TIMESTAMP, and TIMESTAMPTZ, and 9 for TIME_NS and TIMESTAMP_NS. Arrow metadata can supply the physical temporal precision.