View a markdown version of this page

Data type mapping - Amazon Redshift

Amazon Redshift will no longer support the use of Python UDFs after June 30, 2026. We will start enforcing it in phases. For more information on the details of Python end of life and migration options, see the blog post that was published on June 30, 2025.

Data type mapping

The extension maps Redshift result types to DuckDB types as shown in the following table.

Redshift type DuckDB type Notes

BOOLEAN

BOOLEAN

None

SMALLINT

SMALLINT

None

INTEGER

INTEGER

oid values arrive as INTEGER; a value above 2147483647 fails, so cast it with ::bigint in the Redshift SQL.

BIGINT

BIGINT

None

REAL

FLOAT

Sent with 8 significant digits, so a REAL whose first significant digit is 1 can arrive as the neighboring FLOAT (about 1.5% of REAL values). Cast it to DOUBLE PRECISION in the Redshift SQL to read it exactly.

DOUBLE PRECISION

DOUBLE

Exact.

NUMERIC(p,s)

DECIMAL(p,s)

Precision 1 to 38. The extension keeps the Redshift result types.

CHAR(n)

VARCHAR

The extension removes trailing blanks.

VARCHAR(n)

VARCHAR

The extension keeps trailing blanks.

SUPER

VARCHAR

Its JSON text.

DATE

DATE

None

TIME

TIME

Redshift stores 24:00:00 as 00:00:00 and rounds fractions beyond 6 digits, so such values arrive as stored.

TIMETZ

TIME WITH TIME ZONE

Values from a table arrive with offset +00; a constant can keep its offset, and DuckDB compares the offset.

TIMESTAMP

TIMESTAMP

Within DuckDB's range.

TIMESTAMPTZ

TIMESTAMP WITH TIME ZONE

Display and computation follow DuckDB's TimeZone setting and whether its ICU extension is loaded.

VARBYTE

BLOB

None

Unqualified INTERVAL

VARCHAR

The Redshift interval text, such as 1 day 02:00:00. Convert it in the Redshift SQL for a number.

Qualified INTERVAL, GEOMETRY, GEOGRAPHY, and HLLSKETCH

Refused

Convert it in the Redshift SQL.

Any other type

Refused

Cast it to a supported type in the Redshift SQL.

The system-catalog types name and "char" arrive as VARCHAR. A value that doesn't fit its DuckDB type fails the query rather than being rounded or clamped.

Every new connection sets the session's time zone to UTC, its date style to ISO, MDY, its interval style to postgres, and its float output to the most digits Redshift gives, so values arrive in one form. Changing one of these with SET or RESET through redshift_query, including the interval style, which changes the interval text, changes how values arrive for the rest of that session, so leave them as they are.

The known limitations are as follows.

  • The extension refuses qualified INTERVAL, GEOMETRY, GEOGRAPHY, HLLSKETCH, and any other unmapped type at bind, before Redshift runs the statement. Convert them in the Redshift SQL, for example ST_AsText(geom) for a geometry or col::VARCHAR for an interval.

  • REAL values are sent with 8 significant digits, so some 32-bit values arrive as the neighboring FLOAT; DOUBLE PRECISION values arrive exactly. To read a REAL exactly, cast it to DOUBLE PRECISION in the Redshift SQL. A finite value whose printed form overflows fails the query rather than arriving as infinity.

  • oid columns arrive as INTEGER, and a value above 2147483647 fails. Cast it with ::bigint in the Redshift SQL.

  • A TIMESTAMP or TIMESTAMPTZ after 294247-01-10 04:00:54.775806, the end of DuckDB's range, up to Redshift's maximum of 294276-12-31, and a stored TIMESTAMP 'infinity', fail the query. For a write, the failure comes after the statement has run, so check its effects before you run it again.

  • CHAR values lose their trailing blanks, so DuckDB compares and measures them as Redshift does, but some expressions still differ because DuckDB sees the value without Redshift's padding. A CHAR(25) holding 'GERMANY' matches LIKE '%Y' in DuckDB but not in Redshift, octet_length is 7 in DuckDB and 25 in Redshift, and a comparison with a blank-padded literal such as = 'GERMANY ' matches in Redshift but not DuckDB. Run such an expression in the Redshift SQL. A trailing tab is kept, and a case-insensitive Redshift collation doesn't carry over to DuckDB.

redshift_query returns the types Redshift gives the result, which aren't always the ones DuckDB would give the same expression. For example, an aggregate avg of a NUMERIC(10,2) column is DECIMAL(38,2), a window avg(col) OVER (...) keeps DECIMAL(10,2), and NUMERIC(10,2) / 3 is DECIMAL(12,4), where DuckDB would give DOUBLE. These results are truncated, so the average of 10, 20, and 20 arrives as 16.66, and a bare ::numeric is NUMERIC(18,0) in Redshift and DECIMAL(18,3) in DuckDB. Cast in the Redshift SQL to choose the type.

  • A window SUM over a DECIMAL column fails when the total needs more digits than the column's precision, because Redshift declares the result with the column's own precision and scale. Cast the column or the result wider, such as SUM(col::DECIMAL(38,2)) OVER (...).

  • A table Redshift creates with CREATE TABLE AS can hold a wider DECIMAL than the query reported, so reading it back gives the wider type. Declare the columns instead of deriving them to avoid it.

  • Repeated or unnamed result columns, such as SELECT a.id, b.id, arrive with DuckDB's suffixes (id and id_1). Name each column with AS in the Redshift SQL to choose the names.