Appendix C. Data Types in pgpro_axe
pgpro_axe can read many data types that exist in both Postgres Pro and DuckDB. The following data types are currently supported for use in queries:
integer data types (e.g.,
integer,bigint)floating-point data types (e.g.,
real,double precision)numericIt can be internally converted to
double precision. For more information, refer to Section C.1.text/varchar/bpcharbit-related data types, including both fixed- and varied-sized bit arraysbytea/blobtimestamp/timestamptz/date/interval/timestamp_ns/timestamp_ms/timestamp_sbooleanuuidjson/jsonbdomainarraysfor all of the data types aboveFor more information about limitations regarding multi-dimensional arrays, refer to Section C.1.
C.1. Known Limitations #
Currently, pgpro_axe does not support all data types. You might run into the following issues:
enumdata types are not supported.The DuckDB
decimaldata type does not support the wide range of values that the Postgres Pronumericdata type does.To avoid errors when converting between the two,
numericis converted todouble precisioninternally if DuckDB does not support the required precision. This may cause precision loss of the values.The DuckDB
timestamp_nsdata type gets truncated to microseconds when it is converted to the Postgres Protimestampdata type, which loses precision in the output. Operations on atimestamp_nsvalue, such as sorting/grouping/comparing, use the full precision.jsonbcolumns are converted tojsoncolumns when reading from DuckDB. This is because DuckDB does not have thejsonbdata type.Many Postgres Pro
jsonandjsonbfunctions and operators are not implemented in DuckDB. Instead, you can use DuckDBjsonfunctions and operators.For more information about these functions, refer to the official DuckDB documentation.
The DuckDB
tinyintdata type is converted to thechardata type in Postgres Pro, because Postgres Pro does not have thetinyintdata type and displays it as a hex code instead of a regular number.Conversion between Postgres Pro multi-dimensional arrays and DuckDB nested
LISTs in DuckDB can run into various problems due to lack of compatibility between databases.Specifically, in Postgres Pro, different arrays in a column can have different numbers of dimensions, e.g.,
[1]and[[1], [2]]can both occur in the same column. In DuckDB, that is not allowed, and the amount of nesting must always be the same. On the other hand, in DuckDB different lists at the same nest level can contain different numbers of elements, e.g.,[[1], [1, 2]], which is not allowed in Postgres Pro. So conversion between these data types is only possible when the arrays follow the subset.Another possible problem that you can run into is that pgpro_axe uses the Postgres Pro column metadata to determine the number of dimensions that an array has. Since Postgres Pro does not warn you when you add arrays of different dimensions, it is possible that the number of dimensions in the column metadata does not match the actual number of dimensions. To avoid this, alter the column data type:
-- this configures the column to be a 3-dimensional array of text -- ALTER TABLE s ALTER COLUMN a SET DATA TYPE text[][][];
For
domain, whenINSERTis executed, the check regardingdomainis conducted by Postgres Pro, rather than DuckDB. WhenSELECTis executed, and the data type of the queried field isdomain, this field is converted to the corresponding base and handled by DuckDB.