Skip to content

Commit dc200e5

Browse files
committed
improve error messaging
1 parent e423be4 commit dc200e5

6 files changed

Lines changed: 22 additions & 19 deletions

File tree

src/binary_decode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ read_tuple(const chc_column * col, const chc_type * type, uint64_t row,
560560
slot->nulls = (bool *) palloc0(sizeof(bool) * n);
561561
slot->types = (Oid *) palloc0(sizeof(Oid) * n);
562562
slot->len = n;
563+
slot->ch_type_name = chc_type_name(type, NULL);
563564

564565
for (size_t i = 0; i < n; ++i)
565566
{

src/convert.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ ch_binary_init_convert_state(Datum val, Oid intype, Oid outtype)
326326
if (typentry->tupDesc == NULL)
327327
ereport(ERROR,
328328
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
329-
errmsg("type %s is not composite",
329+
errmsg("pg_clickhouse: cannot return %s as %s",
330+
slot->ch_type_name ? slot->ch_type_name : "?",
330331
format_type_be(outtype))));
331332

332333
tupdesc = typentry->tupDesc;

src/include/binary_pg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ typedef struct
4141
bool *nulls;
4242
size_t len;
4343
Oid *types;
44+
const char *ch_type_name;
4445
} ch_binary_tuple_t;
4546

4647
typedef struct

test/expected/json_4.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ SELECT * FROM json_bin.special_keys WHERE data ->> 'my field' = 'hello';
677677
(3 rows)
678678

679679
SELECT * FROM json_bin.special_keys WHERE data ->> 'my field' = 'hello';
680-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
680+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as jsonb
681681
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."my field" = 'hello'))
682682
EXPLAIN (VERBOSE, COSTS OFF)
683683
SELECT * FROM json_http.json_special_keys WHERE data ->> 'my field' = 'hello';
@@ -702,7 +702,7 @@ SELECT * FROM json_bin.json_special_keys WHERE data ->> 'my field' = 'hello';
702702
(3 rows)
703703

704704
SELECT * FROM json_bin.json_special_keys WHERE data ->> 'my field' = 'hello';
705-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
705+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as json
706706
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."my field" = 'hello'))
707707
-- Key with mixed case.
708708
EXPLAIN (VERBOSE, COSTS OFF)
@@ -728,7 +728,7 @@ SELECT * FROM json_bin.special_keys WHERE data ->> 'CamelCase' = 'world';
728728
(3 rows)
729729

730730
SELECT * FROM json_bin.special_keys WHERE data ->> 'CamelCase' = 'world';
731-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
731+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as jsonb
732732
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."CamelCase" = 'world'))
733733
EXPLAIN (VERBOSE, COSTS OFF)
734734
SELECT * FROM json_http.json_special_keys WHERE data ->> 'CamelCase' = 'world';
@@ -753,7 +753,7 @@ SELECT * FROM json_bin.json_special_keys WHERE data ->> 'CamelCase' = 'world';
753753
(3 rows)
754754

755755
SELECT * FROM json_bin.json_special_keys WHERE data ->> 'CamelCase' = 'world';
756-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
756+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as json
757757
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."CamelCase" = 'world'))
758758
-- Key that is a SQL reserved word.
759759
EXPLAIN (VERBOSE, COSTS OFF)
@@ -779,7 +779,7 @@ SELECT * FROM json_bin.special_keys WHERE data ->> 'select' = 'reserved';
779779
(3 rows)
780780

781781
SELECT * FROM json_bin.special_keys WHERE data ->> 'select' = 'reserved';
782-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
782+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as jsonb
783783
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."select" = 'reserved'))
784784
EXPLAIN (VERBOSE, COSTS OFF)
785785
SELECT * FROM json_http.json_special_keys WHERE data ->> 'select' = 'reserved';
@@ -804,7 +804,7 @@ SELECT * FROM json_bin.json_special_keys WHERE data ->> 'select' = 'reserved';
804804
(3 rows)
805805

806806
SELECT * FROM json_bin.json_special_keys WHERE data ->> 'select' = 'reserved';
807-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
807+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as json
808808
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."select" = 'reserved'))
809809
-- Key containing embedded double quotes.
810810
EXPLAIN (VERBOSE, COSTS OFF)

test/expected/json_5.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ SELECT * FROM json_bin.special_keys WHERE data ->> 'my field' = 'hello';
677677
(3 rows)
678678

679679
SELECT * FROM json_bin.special_keys WHERE data ->> 'my field' = 'hello';
680-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
680+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as jsonb
681681
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."my field" = 'hello'))
682682
EXPLAIN (VERBOSE, COSTS OFF)
683683
SELECT * FROM json_http.json_special_keys WHERE data ->> 'my field' = 'hello';
@@ -702,7 +702,7 @@ SELECT * FROM json_bin.json_special_keys WHERE data ->> 'my field' = 'hello';
702702
(3 rows)
703703

704704
SELECT * FROM json_bin.json_special_keys WHERE data ->> 'my field' = 'hello';
705-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
705+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as json
706706
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."my field" = 'hello'))
707707
-- Key with mixed case.
708708
EXPLAIN (VERBOSE, COSTS OFF)
@@ -728,7 +728,7 @@ SELECT * FROM json_bin.special_keys WHERE data ->> 'CamelCase' = 'world';
728728
(3 rows)
729729

730730
SELECT * FROM json_bin.special_keys WHERE data ->> 'CamelCase' = 'world';
731-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
731+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as jsonb
732732
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."CamelCase" = 'world'))
733733
EXPLAIN (VERBOSE, COSTS OFF)
734734
SELECT * FROM json_http.json_special_keys WHERE data ->> 'CamelCase' = 'world';
@@ -753,7 +753,7 @@ SELECT * FROM json_bin.json_special_keys WHERE data ->> 'CamelCase' = 'world';
753753
(3 rows)
754754

755755
SELECT * FROM json_bin.json_special_keys WHERE data ->> 'CamelCase' = 'world';
756-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
756+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as json
757757
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."CamelCase" = 'world'))
758758
-- Key that is a SQL reserved word.
759759
EXPLAIN (VERBOSE, COSTS OFF)
@@ -779,7 +779,7 @@ SELECT * FROM json_bin.special_keys WHERE data ->> 'select' = 'reserved';
779779
(3 rows)
780780

781781
SELECT * FROM json_bin.special_keys WHERE data ->> 'select' = 'reserved';
782-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
782+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as jsonb
783783
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."select" = 'reserved'))
784784
EXPLAIN (VERBOSE, COSTS OFF)
785785
SELECT * FROM json_http.json_special_keys WHERE data ->> 'select' = 'reserved';
@@ -804,7 +804,7 @@ SELECT * FROM json_bin.json_special_keys WHERE data ->> 'select' = 'reserved';
804804
(3 rows)
805805

806806
SELECT * FROM json_bin.json_special_keys WHERE data ->> 'select' = 'reserved';
807-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
807+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as json
808808
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."select" = 'reserved'))
809809
-- Key containing embedded double quotes.
810810
EXPLAIN (VERBOSE, COSTS OFF)

test/expected/json_6.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ SELECT * FROM json_bin.special_keys WHERE data ->> 'my field' = 'hello';
677677
(3 rows)
678678

679679
SELECT * FROM json_bin.special_keys WHERE data ->> 'my field' = 'hello';
680-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
680+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as jsonb
681681
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."my field" = 'hello'))
682682
EXPLAIN (VERBOSE, COSTS OFF)
683683
SELECT * FROM json_http.json_special_keys WHERE data ->> 'my field' = 'hello';
@@ -702,7 +702,7 @@ SELECT * FROM json_bin.json_special_keys WHERE data ->> 'my field' = 'hello';
702702
(3 rows)
703703

704704
SELECT * FROM json_bin.json_special_keys WHERE data ->> 'my field' = 'hello';
705-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
705+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as json
706706
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."my field" = 'hello'))
707707
-- Key with mixed case.
708708
EXPLAIN (VERBOSE, COSTS OFF)
@@ -728,7 +728,7 @@ SELECT * FROM json_bin.special_keys WHERE data ->> 'CamelCase' = 'world';
728728
(3 rows)
729729

730730
SELECT * FROM json_bin.special_keys WHERE data ->> 'CamelCase' = 'world';
731-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
731+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as jsonb
732732
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."CamelCase" = 'world'))
733733
EXPLAIN (VERBOSE, COSTS OFF)
734734
SELECT * FROM json_http.json_special_keys WHERE data ->> 'CamelCase' = 'world';
@@ -753,7 +753,7 @@ SELECT * FROM json_bin.json_special_keys WHERE data ->> 'CamelCase' = 'world';
753753
(3 rows)
754754

755755
SELECT * FROM json_bin.json_special_keys WHERE data ->> 'CamelCase' = 'world';
756-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
756+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as json
757757
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."CamelCase" = 'world'))
758758
-- Key that is a SQL reserved word.
759759
EXPLAIN (VERBOSE, COSTS OFF)
@@ -779,7 +779,7 @@ SELECT * FROM json_bin.special_keys WHERE data ->> 'select' = 'reserved';
779779
(3 rows)
780780

781781
SELECT * FROM json_bin.special_keys WHERE data ->> 'select' = 'reserved';
782-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
782+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as jsonb
783783
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."select" = 'reserved'))
784784
EXPLAIN (VERBOSE, COSTS OFF)
785785
SELECT * FROM json_http.json_special_keys WHERE data ->> 'select' = 'reserved';
@@ -804,7 +804,7 @@ SELECT * FROM json_bin.json_special_keys WHERE data ->> 'select' = 'reserved';
804804
(3 rows)
805805

806806
SELECT * FROM json_bin.json_special_keys WHERE data ->> 'select' = 'reserved';
807-
ERROR: pg_clickhouse: unsupported column type: Tuple(CamelCase String, `my field` String, select String)
807+
ERROR: pg_clickhouse: cannot return Tuple(CamelCase String, `my field` String, select String) as json
808808
DETAIL: Remote Query: SELECT id, data FROM json_test.special_keys WHERE ((data."select" = 'reserved'))
809809
-- Key containing embedded double quotes.
810810
EXPLAIN (VERBOSE, COSTS OFF)

0 commit comments

Comments
 (0)