Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alrocar committed Oct 2, 2024
1 parent cc3f4b5 commit de1cfe0
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 23 deletions.
9 changes: 5 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
version: '2'
services:
clickhouse:
image: yandex/clickhouse-server
image: clickhouse/clickhouse-server:latest
network_mode: "host"
ports:
- "8123:8123"
- "9000:9000"
- 8123:8123
- 9000:9000
volumes:
- ./docker/clickhouse-config.xml:/etc/clickhouse-server/config.xml
- ./docker/clickhouse-users.xml:/etc/clickhouse-server/users.xml
- ./docker/clickhouse-users.xml:/etc/clickhouse-server/users.xml
3 changes: 3 additions & 0 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ ch_http_connection_t *ch_http_connection(char *host, int port, char *username, c

conn->base_url = connstring;
conn->base_url_len = strlen(conn->base_url);

if (database == NULL)
database = "default"; // Set default value
conn->database = malloc(strlen(database));
strcpy(conn->database, database);

Expand Down
4 changes: 2 additions & 2 deletions tests/expected/binary_queries_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work

ALTER SERVER loopback OPTIONS (SET dbname 'no such database');
SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should fail
ERROR: clickhouse_fdw: DB::Exception: Database `no such database` doesn't exist
ERROR: clickhouse_fdw: DB::Exception: Database `no such database` does not exist
ALTER USER MAPPING FOR CURRENT_USER SERVER loopback OPTIONS (ADD user 'no such user');
SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should fail
ERROR: clickhouse_fdw: connection error: DB::Exception: no such user: Authentication failed: password is incorrect or there is no user with such name
ERROR: clickhouse_fdw: connection error: DB::Exception: no such user: Authentication failed: password is incorrect, or there is no user with such name.
ALTER SERVER loopback OPTIONS (SET dbname 'regression');
ALTER USER MAPPING FOR CURRENT_USER SERVER loopback OPTIONS (DROP user);
SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work again
Expand Down
20 changes: 10 additions & 10 deletions tests/expected/functions.out
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,17 @@ SELECT uniq_exact(a) FILTER(WHERE b>1) FROM t1;
(1 row)

EXPLAIN (VERBOSE, COSTS OFF) SELECT c as d1 FROM t1 WHERE c >= to_timestamp('2019-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US') GROUP BY d1 ORDER BY d1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: c
Relations: Aggregate on (t1)
Remote SQL: SELECT c FROM regression.t1 WHERE ((c >= parseDateTimeBestEffortOrNull('2019-01-01 00:00:00.000000'))) GROUP BY c ORDER BY c ASC
(4 rows)

SELECT c as d1 FROM t1 WHERE c >= to_timestamp('2019-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US') GROUP BY d1 ORDER BY d1;
d1
------------------------
d1
---------------------
2019-01-01 10:00:00
2019-01-02 10:00:00
(2 rows)
Expand All @@ -253,7 +253,7 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_trunc('dAy'::text, timezone('UTC'::text, c)))
Output: (date_trunc('dAy'::text, (c AT TIME ZONE 'UTC'::text)))
Relations: Aggregate on (t1)
Remote SQL: SELECT toStartOfDay(toTimeZone(c, 'UTC')) FROM regression.t1 GROUP BY (toStartOfDay(toTimeZone(c, 'UTC'))) ORDER BY toStartOfDay(toTimeZone(c, 'UTC')) ASC
(4 rows)
Expand All @@ -269,7 +269,7 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('day', c at time zone 'UTC') as d
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_trunc('day'::text, timezone('UTC'::text, c)))
Output: (date_trunc('day'::text, (c AT TIME ZONE 'UTC'::text)))
Relations: Aggregate on (t2)
Remote SQL: SELECT toStartOfDay(toTimeZone(c, 'UTC')) FROM regression.t1 GROUP BY (toStartOfDay(toTimeZone(c, 'UTC'))) ORDER BY toStartOfDay(toTimeZone(c, 'UTC')) ASC
(4 rows)
Expand Down Expand Up @@ -361,12 +361,12 @@ SELECT date_part('minuTe'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP B
(1 row)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('SeCond', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_trunc('SeCond'::text, timezone('UTC'::text, c)))
Output: (date_trunc('SeCond'::text, (c AT TIME ZONE 'UTC'::text)))
Relations: Aggregate on (t1)
Remote SQL: SELECT toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1)) FROM regression.t1 GROUP BY (toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1))) ORDER BY toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1)) ASC
Remote SQL: SELECT toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1, 'UTC')) FROM regression.t1 GROUP BY (toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1, 'UTC'))) ORDER BY toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1, 'UTC')) ASC
(4 rows)

SELECT date_trunc('SeCond', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
Expand Down
22 changes: 19 additions & 3 deletions tests/expected/functions_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,22 @@ SELECT uniq_exact(a) FILTER(WHERE b>1) FROM t1;
1
(1 row)

EXPLAIN (VERBOSE, COSTS OFF) SELECT c as d1 FROM t1 WHERE c >= to_timestamp('2019-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US') GROUP BY d1 ORDER BY d1;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: c
Relations: Aggregate on (t1)
Remote SQL: SELECT c FROM regression.t1 WHERE ((c >= parseDateTimeBestEffortOrNull('2019-01-01 00:00:00.000000'))) GROUP BY c ORDER BY c ASC
(4 rows)

SELECT c as d1 FROM t1 WHERE c >= to_timestamp('2019-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US') GROUP BY d1 ORDER BY d1;
d1
---------------------
2019-01-01 10:00:00
2019-01-02 10:00:00
(2 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -345,12 +361,12 @@ SELECT date_part('minuTe'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP B
(1 row)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('SeCond', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_trunc('SeCond'::text, (c AT TIME ZONE 'UTC'::text)))
Relations: Aggregate on (t1)
Remote SQL: SELECT toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1)) FROM regression.t1 GROUP BY (toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1))) ORDER BY toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1)) ASC
Remote SQL: SELECT toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1, 'UTC')) FROM regression.t1 GROUP BY (toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1, 'UTC'))) ORDER BY toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1, 'UTC')) ASC
(4 rows)

SELECT date_trunc('SeCond', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
Expand Down
6 changes: 2 additions & 4 deletions tests/expected/http_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,10 @@ SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work

ALTER SERVER loopback OPTIONS (SET dbname 'no such database');
SELECT c3, c4 FROM ft1 ORDER BY c3, c1; -- should fail
ERROR: clickhouse_fdw:Code: 81. DB::Exception: Database `no such database` doesn't exist. (UNKNOWN_DATABASE)
QUERY:SELECT c1, c3, c4 FROM "no such database".t1 ORDER BY c3 ASC, c1 ASC
ERROR: clickhouse_fdw: communication error: URL rejected: Malformed input to a URL function
ALTER USER MAPPING FOR CURRENT_USER SERVER loopback OPTIONS (ADD user 'no such user');
SELECT c3, c4 FROM ft1 ORDER BY c3, c1; -- should fail
ERROR: clickhouse_fdw:Code: 516. DB::Exception: no such user: Authentication failed: password is incorrect or there is no user with such name. (AUTHENTICATION_FAILED)
QUERY:SELECT c1, c3, c4 FROM "no such database".t1 ORDER BY c3 ASC, c1 ASC
ERROR: clickhouse_fdw: communication error: URL rejected: Malformed input to a URL function
ALTER SERVER loopback OPTIONS (SET dbname 'regression');
ALTER USER MAPPING FOR CURRENT_USER SERVER loopback OPTIONS (DROP user);
SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work again
Expand Down

0 comments on commit de1cfe0

Please sign in to comment.