Skip to content

Commit 8273e91

Browse files
committed
fix(cursor, metadata-queries): support for super, varbyte datatype
1 parent 4cea7df commit 8273e91

File tree

1 file changed

+41
-18
lines changed

1 file changed

+41
-18
lines changed

redshift_connector/cursor.py

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,8 @@ def __build_local_schema_columns_query(
10761076
"when '_int2' THEN 2003 "
10771077
"when 'ARRAY' THEN 2003 "
10781078
"when 'geometry' THEN -4 "
1079-
"when 'omni' THEN -16 "
1079+
"when 'super' THEN -16 "
1080+
"when 'varbyte' THEN -4 "
10801081
"else 1111 END as SMALLINT) AS DATA_TYPE, "
10811082
"t.typname as TYPE_NAME, "
10821083
"case typname "
@@ -1112,7 +1113,8 @@ def __build_local_schema_columns_query(
11121113
"when '_int4' THEN 10 "
11131114
"when '_int2' THEN 5 "
11141115
"when 'geometry' THEN NULL "
1115-
"when 'omni' THEN NULL "
1116+
"when 'super' THEN NULL "
1117+
"when 'varbyte' THEN NULL "
11161118
"else 2147483647 end as COLUMN_SIZE , "
11171119
"null as BUFFER_LENGTH , "
11181120
"case typname "
@@ -1121,7 +1123,8 @@ def __build_local_schema_columns_query(
11211123
"when 'numeric' then (atttypmod - 4) & 65535 "
11221124
"when 'timestamp' then 6 "
11231125
"when 'geometry' then NULL "
1124-
"when 'omni' then NULL "
1126+
"when 'super' then NULL "
1127+
"when 'varbyte' then NULL "
11251128
"else 0 end as DECIMAL_DIGITS, "
11261129
"10 AS NUM_PREC_RADIX , "
11271130
"case a.attnotnull OR (t.typtype = 'd' AND t.typnotnull) "
@@ -1172,7 +1175,8 @@ def __build_local_schema_columns_query(
11721175
"when '_int2' THEN 2003 "
11731176
"when 'ARRAY' THEN 2003 "
11741177
"when 'geometry' THEN -4 "
1175-
"when 'omni' THEN -16 "
1178+
"when 'super' THEN -16 "
1179+
"when 'varbyte' THEN -4 "
11761180
"else 1111 END as SMALLINT) AS SQL_DATA_TYPE, "
11771181
"CAST(NULL AS SMALLINT) as SQL_DATETIME_SUB , "
11781182
"case typname "
@@ -1208,7 +1212,8 @@ def __build_local_schema_columns_query(
12081212
"when '_int4' THEN 10 "
12091213
"when '_int2' THEN 5 "
12101214
"when 'geometry' THEN NULL "
1211-
"when 'omni' THEN NULL "
1215+
"when 'super' THEN NULL "
1216+
"when 'varbyte' THEN NULL "
12121217
"else 2147483647 end as CHAR_OCTET_LENGTH , "
12131218
"a.attnum AS ORDINAL_POSITION, "
12141219
"case a.attnotnull OR (t.typtype = 'd' AND t.typnotnull) "
@@ -1288,7 +1293,8 @@ def __build_local_schema_columns_query(
12881293
"WHEN 'name' THEN 12 "
12891294
"WHEN 'ARRAY' THEN 2003 "
12901295
"WHEN 'geometry' THEN -4 "
1291-
"WHEN 'omni' THEN -16 "
1296+
"WHEN 'super' THEN -16 "
1297+
"WHEN 'varbyte' THEN -4 "
12921298
"ELSE 1111 END AS SMALLINT) AS DATA_TYPE, "
12931299
"COALESCE(NULL,CASE columntype WHEN 'boolean' THEN 'bool' "
12941300
"WHEN 'character varying' THEN 'varchar' "
@@ -1337,7 +1343,8 @@ def __build_local_schema_columns_query(
13371343
"WHEN '_int4' THEN 10 "
13381344
"WHEN '_int2' THEN 5 "
13391345
"WHEN 'geometry' THEN NULL "
1340-
"WHEN 'omni' THEN NULL "
1346+
"WHEN 'super' THEN NULL "
1347+
"WHEN 'varbyte' THEN NULL "
13411348
"ELSE 2147483647 END AS COLUMN_SIZE, "
13421349
"NULL AS BUFFER_LENGTH, "
13431350
"CASE columntype "
@@ -1348,7 +1355,8 @@ def __build_local_schema_columns_query(
13481355
"WHEN 'timestamp' THEN 6 "
13491356
"WHEN 'timestamp without time zone' THEN 6 "
13501357
"WHEN 'geometry' THEN NULL "
1351-
"WHEN 'omni' THEN NULL "
1358+
"WHEN 'super' THEN NULL "
1359+
"WHEN 'varbyte' THEN NULL "
13521360
"ELSE 0 END AS DECIMAL_DIGITS, 10 AS NUM_PREC_RADIX, "
13531361
"NULL AS NULLABLE, NULL AS REMARKS, NULL AS COLUMN_DEF, "
13541362
"CAST(CASE columntype_rep "
@@ -1388,7 +1396,8 @@ def __build_local_schema_columns_query(
13881396
"WHEN 'name' THEN 12 "
13891397
"WHEN 'ARRAY' THEN 2003 "
13901398
"WHEN 'geometry' THEN -4 "
1391-
"WHEN 'omni' THEN -4 "
1399+
"WHEN 'super' THEN -16 "
1400+
"WHEN 'varbyte' THEN -4 "
13921401
"ELSE 1111 END AS SMALLINT) AS SQL_DATA_TYPE, "
13931402
"CAST(NULL AS SMALLINT) AS SQL_DATETIME_SUB, CASE "
13941403
"WHEN LEFT (columntype,7) = 'varchar' THEN regexp_substr (columntype,'[0-9]+',7)::INTEGER "
@@ -1484,7 +1493,8 @@ def __build_universal_schema_columns_query(
14841493
" WHEN 'name' THEN 12"
14851494
" WHEN 'ARRAY' THEN 2003"
14861495
" WHEN 'geometry' THEN -4 "
1487-
" WHEN 'omni' THEN -16 "
1496+
" WHEN 'super' THEN -16 "
1497+
" WHEN 'varbyte' THEN -4 "
14881498
" ELSE 1111 END AS SMALLINT) AS DATA_TYPE,"
14891499
" COALESCE("
14901500
" domain_name,"
@@ -1537,7 +1547,8 @@ def __build_universal_schema_columns_query(
15371547
" WHEN '_int4' THEN 10"
15381548
" WHEN '_int2' THEN 5"
15391549
" WHEN 'geometry' THEN NULL"
1540-
" WHEN 'omni' THEN NULL"
1550+
" WHEN 'super' THEN NULL"
1551+
" WHEN 'varbyte' THEN NULL"
15411552
" ELSE {unknown_column_size}"
15421553
" END AS COLUMN_SIZE,"
15431554
" NULL AS BUFFER_LENGTH,"
@@ -1550,7 +1561,8 @@ def __build_universal_schema_columns_query(
15501561
" WHEN 'timestamp' THEN 6"
15511562
" WHEN 'timestamp without time zone' THEN 6"
15521563
" WHEN 'geometry' THEN NULL"
1553-
" WHEN 'omni' THEN NULL"
1564+
" WHEN 'super' THEN NULL"
1565+
" WHEN 'varbyte' THEN NULL"
15541566
" ELSE 0"
15551567
" END AS DECIMAL_DIGITS,"
15561568
" 10 AS NUM_PREC_RADIX,"
@@ -1596,7 +1608,8 @@ def __build_universal_schema_columns_query(
15961608
" WHEN 'name' THEN 12"
15971609
" WHEN 'ARRAY' THEN 2003"
15981610
" WHEN 'geometry' THEN -4"
1599-
" WHEN 'omni' THEN -16"
1611+
" WHEN 'super' THEN -16"
1612+
" WHEN 'varbyte' THEN -4"
16001613
" ELSE 1111 END AS SMALLINT) AS SQL_DATA_TYPE,"
16011614
" CAST(NULL AS SMALLINT) AS SQL_DATETIME_SUB,"
16021615
" CASE data_type"
@@ -1635,7 +1648,8 @@ def __build_universal_schema_columns_query(
16351648
" WHEN '_int4' THEN 10"
16361649
" WHEN '_int2' THEN 5"
16371650
" WHEN 'geometry' THEN NULL"
1638-
" WHEN 'omni' THEN NULL"
1651+
" WHEN 'super' THEN NULL"
1652+
" WHEN 'varbyte' THEN NULL"
16391653
" ELSE {unknown_column_size}"
16401654
" END AS CHAR_OCTET_LENGTH,"
16411655
" ordinal_position AS ORDINAL_POSITION,"
@@ -1713,6 +1727,7 @@ def __build_universal_all_schema_columns_query(
17131727
" WHEN 'ARRAY' THEN 2003 "
17141728
" WHEN 'geometry' THEN -4 "
17151729
" WHEN 'super' THEN -16 "
1730+
" WHEN 'varbyte' THEN -4 "
17161731
" ELSE 1111 END AS SMALLINT) AS DATA_TYPE, "
17171732
" CASE data_type "
17181733
" WHEN 'boolean' THEN 'bool' "
@@ -1764,6 +1779,7 @@ def __build_universal_all_schema_columns_query(
17641779
" WHEN '_int2' THEN 5 "
17651780
" WHEN 'geometry' THEN NULL "
17661781
" WHEN 'super' THEN NULL "
1782+
" WHEN 'varbyte' THEN NULL "
17671783
" ELSE 2147483647 "
17681784
" END AS COLUMN_SIZE, "
17691785
" NULL AS BUFFER_LENGTH, "
@@ -1777,6 +1793,7 @@ def __build_universal_all_schema_columns_query(
17771793
" WHEN 'timestamp without time zone' THEN 6 "
17781794
" WHEN 'geometry' THEN NULL "
17791795
" WHEN 'super' THEN NULL "
1796+
" WHEN 'varbyte' THEN NULL "
17801797
" ELSE 0 "
17811798
" END AS DECIMAL_DIGITS, "
17821799
" 10 AS NUM_PREC_RADIX, "
@@ -1823,6 +1840,7 @@ def __build_universal_all_schema_columns_query(
18231840
" WHEN 'ARRAY' THEN 2003 "
18241841
" WHEN 'geometry' THEN -4 "
18251842
" WHEN 'super' THEN -16 "
1843+
" WHEN 'varbyte' THEN -4 "
18261844
" ELSE 1111 END AS SMALLINT) AS SQL_DATA_TYPE, "
18271845
" CAST(NULL AS SMALLINT) AS SQL_DATETIME_SUB, "
18281846
" CASE data_type "
@@ -1862,6 +1880,7 @@ def __build_universal_all_schema_columns_query(
18621880
" WHEN '_int2' THEN 5 "
18631881
" WHEN 'geometry' THEN NULL "
18641882
" WHEN 'super' THEN NULL "
1883+
" WHEN 'varbyte' THEN NULL "
18651884
" ELSE 2147483647 "
18661885
" END AS CHAR_OCTET_LENGTH, "
18671886
" ordinal_position AS ORDINAL_POSITION, "
@@ -1939,7 +1958,8 @@ def __build_external_schema_columns_query(
19391958
" WHEN external_type = 'name' THEN 12"
19401959
" WHEN external_type = 'ARRAY' THEN 2003"
19411960
" WHEN external_type = 'geometry' THEN -4"
1942-
" WHEN external_type = 'omni' THEN -16"
1961+
" WHEN external_type = 'super' THEN -16"
1962+
" WHEN external_type = 'varbyte' THEN -4"
19431963
" ELSE 1111 END AS SMALLINT) AS DATA_TYPE,"
19441964
" CASE WHEN left(external_type, 17) = 'character varying' THEN 'varchar'"
19451965
" WHEN left(external_type, 7) = 'varchar' THEN 'varchar'"
@@ -1987,7 +2007,8 @@ def __build_external_schema_columns_query(
19872007
" WHEN external_type = '_int4' THEN 10"
19882008
" WHEN external_type = '_int2' THEN 5"
19892009
" WHEN external_type = 'geometry' THEN NULL"
1990-
" WHEN external_type = 'omni' THEN NULL"
2010+
" WHEN external_type = 'super' THEN NULL"
2011+
" WHEN external_type = 'varbyte' THEN NULL"
19912012
" ELSE 2147483647 END AS COLUMN_SIZE,"
19922013
" NULL AS BUFFER_LENGTH,"
19932014
" CASE WHEN external_type = 'real'THEN 8"
@@ -2000,7 +2021,8 @@ def __build_external_schema_columns_query(
20002021
" WHEN external_type = 'timestamp' THEN 6"
20012022
" WHEN external_type = 'timestamp without time zone' THEN 6"
20022023
" WHEN external_type = 'geometry' THEN NULL"
2003-
" WHEN external_type = 'omni' THEN NULL"
2024+
" WHEN external_type = 'super' THEN NULL"
2025+
" WHEN external_type = 'varbyte' THEN NULL"
20042026
" ELSE 0 END AS DECIMAL_DIGITS,"
20052027
" 10 AS NUM_PREC_RADIX,"
20062028
" NULL AS NULLABLE,"
@@ -2047,7 +2069,8 @@ def __build_external_schema_columns_query(
20472069
" WHEN external_type = 'name' THEN 12"
20482070
" WHEN external_type = 'ARRAY' THEN 2003"
20492071
" WHEN external_type = 'geometry' THEN -4"
2050-
" WHEN external_type = 'omni' THEN -16"
2072+
" WHEN external_type = 'super' THEN -16"
2073+
" WHEN external_type = 'varbyte' THEN -4"
20512074
" ELSE 1111 END AS SMALLINT) AS SQL_DATA_TYPE,"
20522075
" CAST(NULL AS SMALLINT) AS SQL_DATETIME_SUB,"
20532076
" CASE WHEN left(external_type, 7) = 'varchar' THEN regexp_substr(external_type, '[0-9]+', 7)::integer"

0 commit comments

Comments
 (0)