Skip to content

Commit

Permalink
Add DuckDB Example to load data for docker compose (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
goldmedal authored Mar 21, 2024
1 parent 1edeeea commit 2572d49
Show file tree
Hide file tree
Showing 20 changed files with 451 additions and 20 deletions.
23 changes: 3 additions & 20 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
# Description

This is an example Docker Compose project for running the Wren Engine.
This is some example Docker Compose project for different data source types. Please go to the respective directory for more information.

# How to use

1. Set up the platform in `.env` file. (`linux/amd64`, `linux/arm64`)
2. Configure settings in the `etc/config.properties` file.
3. Place your MDL in `etc/mdl` file after removing the sample MDL file `etc/mdl/sample.json`.
- The `mdl` directory should contain only one json file.
4. Set up the accounts if you needs or remove the sample accounts if you don't need.
- Sample accounts are provided in the `etc/accounts` directory.
5. Run the docker-compose
```bash
docker compose --env-file .env up
```
6. Connect using psql or another PostgreSQL driver using port 7432.
- Sample usernames and passwords are `ina` and `wah`, or `azki` and `guess`.
- The default database name should match the catalog of the MDL file.
- The default schema name should match the schema of the MDL file.
```bash
psql 'host=localhost user=ina dbname=test_catalog port=7432 options=--search_path=test_schema'
```
- [BigQuery Example](bigquery-example/README.md)
- [DuckDB TPCH Example](duckdb-tpch-example/README.md)
1 change: 1 addition & 0 deletions example/bigquery-example/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PLATFORM=linux/amd64
23 changes: 23 additions & 0 deletions example/bigquery-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Description

This is an example Docker Compose project for running the Wren Engine.

# How to use

1. Set up the platform in `.env` file. (`linux/amd64`, `linux/arm64`)
2. Configure settings in the `etc/config.properties` file.
3. Place your MDL in `etc/mdl` file after removing the sample MDL file `etc/mdl/sample.json`.
- The `mdl` directory should contain only one json file.
4. Set up the accounts if you needs or remove the sample accounts if you don't need.
- Sample accounts are provided in the `etc/accounts` directory.
5. Run the docker-compose in this directory.
```bash
docker compose --env-file .env up
```
6. Connect using psql or another PostgreSQL driver using port 7432.
- Sample usernames and passwords are `ina` and `wah`, or `azki` and `guess`.
- The default database name should match the catalog of the MDL file.
- The default schema name should match the schema of the MDL file.
```bash
psql 'host=localhost user=ina dbname=test_catalog port=7432 options=--search_path=test_schema'
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions example/.env → example/duckdb-tpch-example/.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
PLATFORM=linux/amd64
ETC_PATH=./etc
26 changes: 26 additions & 0 deletions example/duckdb-tpch-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Description

This is an example Docker Compose project for DuckDB data source with some tpch data.
You can learn how to set up the Wren Engine with DuckDB data source to analyze your data.

# How to use

1. Set up the platform in `.env` file. (`linux/amd64`, `linux/arm64`)
2. Configure settings in the `etc/config.properties` file.
3. Place your data in `etc/data` file after removing the sample data files.
4. Set up your initial SQL and session SQL in `etc/duckdb-init.sql` and `etc/duckdb-session.sql` files.
5. Place your MDL in `etc/mdl` file after removing the sample MDL file `etc/mdl/sample.json`.
- The `mdl` directory should contain only one json file.
6. Set up the accounts if you needs or remove the sample accounts if you don't need.
- Sample accounts are provided in the `etc/accounts` directory.
7. Run the docker-compose in this directory.
```bash
docker compose --env-file .env up
```
8. Connect using psql or another PostgreSQL driver using port 7432.
- Sample usernames and passwords are `ina` and `wah`, or `azki` and `guess`.
- The default database name should match the catalog of the MDL file.
- The default schema name should match the schema of the MDL file.
```bash
psql 'host=localhost user=ina dbname=wren port=7432 options=--search_path=tpch'
```
Binary file not shown.
Binary file added example/duckdb-tpch-example/data/lineitem.parquet
Binary file not shown.
Binary file added example/duckdb-tpch-example/data/nation.parquet
Binary file not shown.
Binary file added example/duckdb-tpch-example/data/orders.parquet
Binary file not shown.
Binary file added example/duckdb-tpch-example/data/part.parquet
Binary file not shown.
12 changes: 12 additions & 0 deletions example/duckdb-tpch-example/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.8'

services:
engine:
image: ghcr.io/canner/wren-engine:latest
platform: ${PLATFORM}
ports:
- 8080:8080
- 7432:7432
volumes:
- ./etc:/usr/src/app/etc
- ./data:/usr/src/app/data
2 changes: 2 additions & 0 deletions example/duckdb-tpch-example/etc/accounts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ina wah
azki guess
22 changes: 22 additions & 0 deletions example/duckdb-tpch-example/etc/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# /*
# * Licensed under the Apache License, Version 2.0 (the "License");
# * you may not use this file except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# */
#
node.environment=production
wren.directory=/usr/src/app/etc/mdl
pg-wire-protocol.auth.file=/usr/src/app/etc/accounts
wren.experimental-enable-dynamic-fields=false
wren.datasource.type=duckdb
duckdb.connector.init-sql-path=/usr/src/app/etc/duckdb-init.sql
duckdb.connector.session-sql-path=/usr/src/app/etc/mdl/duckdb-session.sql
6 changes: 6 additions & 0 deletions example/duckdb-tpch-example/etc/duckdb-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE SCHEMA tpch;
CREATE TABLE tpch.customer AS SELECT * FROM read_parquet('/usr/src/app/data/customer.parquet');
CREATE TABLE tpch.lineitem AS SELECT * FROM read_parquet('/usr/src/app/data/lineitem.parquet');
CREATE TABLE tpch.nation AS SELECT * FROM read_parquet('/usr/src/app/data/nation.parquet');
CREATE TABLE tpch.orders AS SELECT * FROM read_parquet('/usr/src/app/data/orders.parquet');
CREATE TABLE tpch.part AS SELECT * FROM read_parquet('/usr/src/app/data/part.parquet');
Empty file.
Loading

0 comments on commit 2572d49

Please sign in to comment.