-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bootstrap MyDuck Server with DuckDB (#154)
--------- Co-authored-by: Fan Yang <[email protected]>
- Loading branch information
1 parent
3e9e0e0
commit d2066c5
Showing
9 changed files
with
117 additions
and
6 deletions.
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
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,22 @@ | ||
package catalog | ||
|
||
var SystemViews = map[string]struct{}{ | ||
"duckdb_columns": {}, | ||
"duckdb_constraints": {}, | ||
"duckdb_databases": {}, | ||
"duckdb_indexes": {}, | ||
"duckdb_schemas": {}, | ||
"duckdb_tables": {}, | ||
"duckdb_types": {}, | ||
"duckdb_views": {}, | ||
"pragma_database_list": {}, | ||
"sqlite_master": {}, | ||
"sqlite_schema": {}, | ||
"sqlite_temp_master": {}, | ||
"sqlite_temp_schema": {}, | ||
} | ||
|
||
func IsSystemView(viewName string) bool { | ||
_, ok := SystemViews[viewName] | ||
return ok | ||
} |
Binary file not shown.
Binary file not shown.
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,34 @@ | ||
# Bootstrapping from an existing DuckDB file | ||
|
||
Given an existing DuckDB file, it is possible to bootstrap MyDuck Server with it or serve it with MyDuck Server. | ||
Here’s how to work with the `example.db` file located in `docs/data/`. | ||
|
||
### Steps | ||
|
||
1. **Prepare the data directory:** | ||
```bash | ||
mkdir example_data | ||
cp /path/to/example.db example_data/mysql.db # IMPORTANT: The attached filename must be `mysql.db` | ||
``` | ||
|
||
2. **Launch MyDuck Server and attach the data directory:** | ||
```bash | ||
docker run \ | ||
-p 13306:3306 \ | ||
-p 15432:5432 \ | ||
--volume=/path/to/example_data:/home/admin/data \ | ||
apecloud/myduckserver:main | ||
``` | ||
|
||
3. **Connect to MyDuck Server and query:** | ||
```bash | ||
# Using psql client & DuckDB syntax | ||
psql -h 127.0.0.1 -p 15432 -U mysql <<EOF | ||
SELECT * FROM "test_data"; | ||
EOF | ||
# Or using MySQL client & syntax | ||
mysql -h 127.0.0.1 -uroot -P13306 main <<EOF | ||
SELECT * FROM `test_data`; | ||
EOF | ||
``` |
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,41 @@ | ||
# Query & Load Parquet Files | ||
|
||
Imagine you have a large dataset stored in Parquet files. You want to share this data with your team, enabling them to query it using SQL. | ||
However, these files are too large to be stored locally and too slow to download from cloud storage every time. | ||
You can put these files on a server that is accessible to your team and run a MyDuck Server instance on it. | ||
Then, your team can query the dataset easily with either a Postgres or a MySQL client. | ||
|
||
Below, we’ll show you how to query and load the `example.parquet` file from the `docs/data/` directory by attaching it into a MyDuck Server container. | ||
|
||
## Steps | ||
|
||
1. **Run MyDuck Server:** | ||
```bash | ||
docker run -p 13306:3306 -p 15432:5432 \ | ||
-v /path/to/example.parquet:/home/admin/data/example.parquet \ | ||
apecloud/myduckserver:main | ||
``` | ||
|
||
2. **Connect to MyDuck Server using `psql`:** | ||
```bash | ||
psql -h 127.0.0.1 -p 15432 -U mysql | ||
``` | ||
|
||
3. **Query the Parquet file directly:** | ||
```sql | ||
SELECT * FROM '/home/admin/data/example.parquet' LIMIT 10; | ||
``` | ||
|
||
4. **Load the Parquet file into a DuckDB table:** | ||
```sql | ||
CREATE TABLE test_data AS SELECT * FROM '/home/admin/data/example.parquet'; | ||
SELECT * FROM test_data LIMIT 10; | ||
``` | ||
|
||
5. **Query the data with MySQL client & syntax:** | ||
```bash | ||
mysql -h 127.0.0.1 -uroot -P13306 main | ||
``` | ||
```sql | ||
SELECT * FROM `test_data`; | ||
``` |