CREATE SERVER casts_loopback FOREIGN DATA WRAPPER clickhouse_fdw OPTIONS(dbname 'casts_test', driver 'binary'); CREATE USER MAPPING FOR CURRENT_USER SERVER casts_loopback; SELECT clickhouse_raw_query('DROP DATABASE IF EXISTS casts_test'); clickhouse_raw_query ---------------------- (1 row) SELECT clickhouse_raw_query('CREATE DATABASE casts_test'); clickhouse_raw_query ---------------------- (1 row) SELECT clickhouse_raw_query($$ CREATE TABLE casts_test.things ( num integer, name text ) ENGINE = MergeTree ORDER BY (num); $$); clickhouse_raw_query ---------------------- (1 row) SELECT clickhouse_raw_query($$ INSERT INTO casts_test.things SELECT number, toString(number) FROM numbers(10); $$); clickhouse_raw_query ---------------------- (1 row) IMPORT FOREIGN SCHEMA casts_test FROM SERVER casts_loopback INTO public; EXPLAIN (VERBOSE, COSTS OFF) SELECT num FROM things WHERE toUInt8(num) IN (8, 3, 5); QUERY PLAN ----------------------------------------------------------------------------------- Foreign Scan on public.things Output: num Remote SQL: SELECT num FROM casts_test.things WHERE ((toUInt8(num) IN (8,3,5))) (3 rows) SELECT num FROM things WHERE toUInt8(num) IN (8, 3, 5); num ----- 3 5 8 (3 rows) EXPLAIN (VERBOSE, COSTS OFF) SELECT num FROM things WHERE toUInt8(name) IN (1, 2, 3); QUERY PLAN ------------------------------------------------------------------------------------ Foreign Scan on public.things Output: num Remote SQL: SELECT num FROM casts_test.things WHERE ((toUInt8(name) IN (1,2,3))) (3 rows) SELECT num FROM things WHERE toUInt8(name) IN (1, 2, 3); num ----- 1 2 3 (3 rows) EXPLAIN (VERBOSE, COSTS OFF) SELECT num FROM things WHERE toUint16(num) IN (8, 3, 5); QUERY PLAN ------------------------------------------------------------------------------------ Foreign Scan on public.things Output: num Remote SQL: SELECT num FROM casts_test.things WHERE ((toUInt16(num) IN (8,3,5))) (3 rows) SELECT num FROM things WHERE toUint16(num) IN (8, 3, 5); num ----- 3 5 8 (3 rows) EXPLAIN (VERBOSE, COSTS OFF) SELECT num FROM things WHERE toUint16(name) IN (1, 2, 3); QUERY PLAN ------------------------------------------------------------------------------------- Foreign Scan on public.things Output: num Remote SQL: SELECT num FROM casts_test.things WHERE ((toUInt16(name) IN (1,2,3))) (3 rows) SELECT num FROM things WHERE toUint16(name) IN (1, 2, 3); num ----- 1 2 3 (3 rows) EXPLAIN (VERBOSE, COSTS OFF) SELECT num FROM things WHERE toUint32(num) IN (8, 3, 5); QUERY PLAN ------------------------------------------------------------------------------------ Foreign Scan on public.things Output: num Remote SQL: SELECT num FROM casts_test.things WHERE ((toUInt32(num) IN (8,3,5))) (3 rows) SELECT num FROM things WHERE toUint32(num) IN (8, 3, 5); num ----- 3 5 8 (3 rows) EXPLAIN (VERBOSE, COSTS OFF) SELECT num FROM things WHERE toUint32(name) IN (1, 2, 3); QUERY PLAN ------------------------------------------------------------------------------------- Foreign Scan on public.things Output: num Remote SQL: SELECT num FROM casts_test.things WHERE ((toUInt32(name) IN (1,2,3))) (3 rows) SELECT num FROM things WHERE toUint32(name) IN (1, 2, 3); num ----- 1 2 3 (3 rows) EXPLAIN (VERBOSE, COSTS OFF) SELECT num FROM things WHERE toUint64(num) IN (8, 3, 5); QUERY PLAN ------------------------------------------------------------------------------------ Foreign Scan on public.things Output: num Remote SQL: SELECT num FROM casts_test.things WHERE ((toUInt64(num) IN (8,3,5))) (3 rows) SELECT num FROM things WHERE toUint64(num) IN (8, 3, 5); num ----- 3 5 8 (3 rows) EXPLAIN (VERBOSE, COSTS OFF) SELECT num FROM things WHERE toUint64(name) IN (1, 2, 3); QUERY PLAN ------------------------------------------------------------------------------------- Foreign Scan on public.things Output: num Remote SQL: SELECT num FROM casts_test.things WHERE ((toUInt64(name) IN (1,2,3))) (3 rows) SELECT num FROM things WHERE toUint64(name) IN (1, 2, 3); num ----- 1 2 3 (3 rows) EXPLAIN (VERBOSE, COSTS OFF) SELECT num FROM things WHERE toUint128(num) IN (8, 3, 5); QUERY PLAN ------------------------------------------------------------------------------------- Foreign Scan on public.things Output: num Remote SQL: SELECT num FROM casts_test.things WHERE ((toUInt128(num) IN (8,3,5))) (3 rows) SELECT num FROM things WHERE toUint128(num) IN (8, 3, 5); num ----- 3 5 8 (3 rows) EXPLAIN (VERBOSE, COSTS OFF) SELECT num FROM things WHERE toUint128(name) IN (1, 2, 3); QUERY PLAN -------------------------------------------------------------------------------------- Foreign Scan on public.things Output: num Remote SQL: SELECT num FROM casts_test.things WHERE ((toUInt128(name) IN (1,2,3))) (3 rows) SELECT num FROM things WHERE toUint128(name) IN (1, 2, 3); num ----- 1 2 3 (3 rows) DROP USER MAPPING FOR CURRENT_USER SERVER casts_loopback; SELECT clickhouse_raw_query('DROP DATABASE casts_test'); clickhouse_raw_query ---------------------- (1 row) DROP SERVER casts_loopback CASCADE; NOTICE: drop cascades to foreign table things