-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43cebe1
commit aa409a2
Showing
9 changed files
with
181 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
services: | ||
|
||
trino: | ||
volumes: | ||
- ./modules/catalog/clickhouse/resources/trino/clickhouse.properties:${ETC}/catalog/clickhouse.properties | ||
|
||
clickhouse: | ||
image: clickhouse/clickhouse-server:${CLICKHOUSE_VER} | ||
container_name: clickhouse | ||
env_file: | ||
- ./modules/catalog/clickhouse/resources/clickhouse/clickhouse.env | ||
ports: | ||
- :8123 | ||
volumes: | ||
- ./modules/catalog/clickhouse/resources/clickhouse/init.sh:/docker-entrypoint-initdb.d/init.sh | ||
labels: | ||
- com.starburst.tests=minitrino | ||
- com.starburst.tests.module.clickhouse=catalog-clickhouse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"description": "ClickHouse catalog module", | ||
"incompatibleModules": [], | ||
"enterprise": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# ClickHouse Catalog Module | ||
|
||
This module provisions a ClickHouse server with some preloaded data. The | ||
preloaded tables are stored in the `minitrino` ClickHouse database, which is | ||
exposed as the `clickhouse.minitrino` schema in Trino. | ||
|
||
## Loading Data | ||
|
||
Data is loaded by mounting a shell script to the ClickHouse container's | ||
`docker-entrypoint-initdb.d/` directory. Scripts in this directory are executed | ||
whenever the container boots up, and is the ClickHouse-supported method for | ||
bootstrapping ClickHouse containers. | ||
|
||
The init script can be edited in the library to load different tables and/or | ||
additional data: | ||
|
||
lib/modules/catalog/clickhouse/resources/clickhouse/init.sh | ||
|
||
## Usage | ||
|
||
minitrino --env STARBURST_VER=<ver> provision --module clickhouse | ||
docker exec -it trino bash | ||
trino-cli | ||
trino> show tables in clickhouse.minitrino; |
4 changes: 4 additions & 0 deletions
4
src/lib/modules/catalog/clickhouse/resources/clickhouse/clickhouse.env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CLICKHOUSE_DB=minitrino | ||
CLICKHOUSE_USER=admin | ||
CLICKHOUSE_PASSWORD=trinoRocks15 | ||
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 |
52 changes: 52 additions & 0 deletions
52
src/lib/modules/catalog/clickhouse/resources/clickhouse/init.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo "Creating three sample tables..." | ||
|
||
clickhouse client -n <<-EOSQL | ||
CREATE TABLE IF NOT EXISTS minitrino.table1 ( | ||
id UInt32, | ||
name String, | ||
value Float64 | ||
) ENGINE = MergeTree() | ||
ORDER BY id; | ||
CREATE TABLE IF NOT EXISTS minitrino.table2 ( | ||
id UInt32, | ||
category String, | ||
amount Decimal(10, 2) | ||
) ENGINE = MergeTree() | ||
ORDER BY id; | ||
CREATE TABLE IF NOT EXISTS minitrino.table3 ( | ||
id UInt32, | ||
timestamp DateTime, | ||
is_active UInt8 | ||
) ENGINE = MergeTree() | ||
ORDER BY id; | ||
-- Insert random data into table1 | ||
INSERT INTO minitrino.table1 | ||
SELECT | ||
number AS id, | ||
concat('Name_', toString(number % 100)) AS name, | ||
rand() % 10000 / 100.0 AS value | ||
FROM numbers(1000); | ||
-- Insert random data into table2 | ||
INSERT INTO minitrino.table2 | ||
SELECT | ||
number AS id, | ||
concat('Category_', toString(rand() % 10)) AS category, | ||
rand() % 5000 / 100.0 AS amount | ||
FROM numbers(1000); | ||
-- Insert random data into table3 | ||
INSERT INTO minitrino.table3 | ||
SELECT | ||
number AS id, | ||
now() - number * 60 AS timestamp, | ||
rand() % 2 AS is_active | ||
FROM numbers(1000); | ||
EOSQL |
5 changes: 5 additions & 0 deletions
5
src/lib/modules/catalog/clickhouse/resources/trino/clickhouse.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
connector.name=clickhouse | ||
connection-url=jdbc:clickhouse://clickhouse:8123 | ||
connection-user=admin | ||
connection-password=trinoRocks15 | ||
case-insensitive-name-matching=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
"tests": [ | ||
{ | ||
"type": "query", | ||
"name": "Test create schema", | ||
"sql": "CREATE SCHEMA clickhouse.test_schema", | ||
"trinoCliArgs": [ | ||
"--server 'http://trino:8080'", | ||
"--user admin" | ||
], | ||
"contains": [ | ||
"CREATE SCHEMA" | ||
] | ||
}, | ||
{ | ||
"type": "query", | ||
"name": "Test schema list", | ||
"sql": "SHOW SCHEMAS IN clickhouse", | ||
"trinoCliArgs": [ | ||
"--server 'http://trino:8080'", | ||
"--user admin" | ||
], | ||
"contains": [ | ||
"information_schema", | ||
"test_schema", | ||
"minitrino" | ||
] | ||
}, | ||
{ | ||
"type": "query", | ||
"name": "Test table list", | ||
"sql": "SHOW TABLES IN clickhouse.minitrino", | ||
"trinoCliArgs": [ | ||
"--server 'http://trino:8080'", | ||
"--user admin" | ||
], | ||
"contains": [ | ||
"table1", | ||
"table2", | ||
"table3" | ||
] | ||
}, | ||
{ | ||
"type": "query", | ||
"name": "Test CTAS", | ||
"sql": "CREATE TABLE clickhouse.test_schema.test_table AS SELECT * FROM tpch.tiny.customer LIMIT 10", | ||
"trinoCliArgs": [ | ||
"--server 'http://trino:8080'", | ||
"--user admin" | ||
], | ||
"contains": [ | ||
"CREATE TABLE: 10 rows" | ||
] | ||
}, | ||
{ | ||
"type": "query", | ||
"name": "Test table select", | ||
"sql": "SELECT * FROM clickhouse.test_schema.test_table LIMIT 10", | ||
"trinoCliArgs": [ | ||
"--server 'http://trino:8080'", | ||
"--user admin" | ||
], | ||
"contains": [ | ||
"custkey", | ||
"name", | ||
"address" | ||
] | ||
} | ||
] | ||
} |