Skip to content

Commit

Permalink
Merge pull request #419 from bruin-data/patch/clickhouse-template-doc…
Browse files Browse the repository at this point in the history
…-plus-amends

add clickhouse temaplte docs and better error messages
  • Loading branch information
albertobruin authored Jan 24, 2025
2 parents 42b8cfb + 7a12ace commit 0ecd685
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default defineConfig({
collapsed: true,
items: [
{ text: "athena", link: "/getting-started/templates-docs/athena-README.md" },
{ text: "clickhouse", link: "/getting-started/templates-docs/clickhouse-README.md" },
{ text: "chess", link: "/getting-started/templates-docs/chess-README.md" },
{ text: "duckdb", link: "/getting-started/templates-docs/duckdb-README.md" },
{ text: "firebase", link: "/getting-started/templates-docs/firebase-README.md" },
Expand Down
60 changes: 60 additions & 0 deletions docs/getting-started/templates-docs/clickhouse-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Bruin - Clickhouse Template

This pipeline is a simple example of a Bruin pipeline for Clickhouse,
featuring `example.sql`—a SQL asset that creates a table with sample data and enforces schema constraints
like `not_null`, `unique`, and `primary_key`.

## Setup
The pipeline already includes an empty `.bruin.yml` file, fill it with your connections and environments. You can read more about connections [here](https://bruin-data.github.io/bruin/connections/gorgias.html).
You will need a clickhouse server. You can run one locally with docker running the following:

```bash
docker run -e CLICKHOUSE_DB=default -e CLICKHOUSE_USER=username -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=password -p 18123:8123 -p19000:9000 --name some-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server
```

Here's a sample `.bruin.yml` file that would work with the docker container above:


```yaml
default_environment: default
environments:
default:
connections:
clickhouse:
- name: clickhouse-default
username: username
password: password
host: 127.0.0.1
port: 19000
database: my_database
```
## Running the pipeline
bruin CLI can run the whole pipeline or any task with the downstreams:
```shell

bruin run ./clickhouse/pipeline.yml
```

You can also run a single task:

```shell
bruin run assets/hello.py
```

```shell
Starting the pipeline execution...

[2023-03-16T18:25:59Z] [worker-0] Running: hello
[2023-03-16T18:26:00Z] [worker-0] [hello] >> Hello, world!
[2023-03-16T18:26:00Z] [worker-0] Completed: hello (103ms)


Executed 1 tasks in 103ms
```

You can optionally pass a `--downstream` flag to run the task with all of its downstreams.

That's it, good luck!
2 changes: 1 addition & 1 deletion pkg/athena/materialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var matMap = AssetMaterializationMap{
}

func errorMaterializer(asset *pipeline.Asset, query, location string) ([]string, error) {
return []string{}, fmt.Errorf("materialization strategy %s is not supported for materialization type %s", asset.Materialization.Strategy, asset.Materialization.Type)
return nil, fmt.Errorf("materialization strategy %s is not supported for materialization type %s and asset type %s", asset.Materialization.Strategy, asset.Materialization.Type, asset.Type)
}

func viewMaterializer(asset *pipeline.Asset, query, location string) ([]string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/bigquery/materialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewMaterializer(fullRefresh bool) *pipeline.Materializer {
}

func errorMaterializer(asset *pipeline.Asset, query string) (string, error) {
return "", fmt.Errorf("materialization strategy %s is not supported for materialization type %s", asset.Materialization.Strategy, asset.Materialization.Type)
return "", fmt.Errorf("materialization strategy %s is not supported for materialization type %s and asset type %s", asset.Materialization.Strategy, asset.Materialization.Type, asset.Type)
}

func viewMaterializer(asset *pipeline.Asset, query string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/clickhouse/materialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var matMap = AssetMaterializationMap{
}

func errorMaterializer(asset *pipeline.Asset, query string) ([]string, error) {
return nil, fmt.Errorf("materialization strategy %s is not supported for materialization type %s", asset.Materialization.Strategy, asset.Materialization.Type)
return nil, fmt.Errorf("materialization strategy %s is not supported for materialization type %s and asset type %s", asset.Materialization.Strategy, asset.Materialization.Type, asset.Type)
}

func viewMaterializer(asset *pipeline.Asset, query string) ([]string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/databricks/materialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var matMap = AssetMaterializationMap{
}

func errorMaterializer(asset *pipeline.Asset, query string) ([]string, error) {
return []string{}, fmt.Errorf("materialization strategy %s is not supported for materialization type %s", asset.Materialization.Strategy, asset.Materialization.Type)
return nil, fmt.Errorf("materialization strategy %s is not supported for materialization type %s and asset type %s", asset.Materialization.Strategy, asset.Materialization.Type, asset.Type)
}

func viewMaterializer(asset *pipeline.Asset, query string) ([]string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/duckdb/materialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var matMap = pipeline.AssetMaterializationMap{
}

func errorMaterializer(asset *pipeline.Asset, query string) (string, error) {
return "", fmt.Errorf("materialization strategy %s is not supported for materialization type %s", asset.Materialization.Strategy, asset.Materialization.Type)
return "", fmt.Errorf("materialization strategy %s is not supported for materialization type %s and asset type %s", asset.Materialization.Strategy, asset.Materialization.Type, asset.Type)
}

func viewMaterializer(asset *pipeline.Asset, query string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/mssql/materialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewMaterializer(fullRefresh bool) *pipeline.Materializer {
}

func errorMaterializer(asset *pipeline.Asset, query string) (string, error) {
return "", fmt.Errorf("materialization strategy %s is not supported for materialization type %s", asset.Materialization.Strategy, asset.Materialization.Type)
return "", fmt.Errorf("materialization strategy %s is not supported for materialization type %s and asset type %s", asset.Materialization.Strategy, asset.Materialization.Type, asset.Type)
}

func viewMaterializer(asset *pipeline.Asset, query string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/postgres/materialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var matMap = pipeline.AssetMaterializationMap{
}

func errorMaterializer(asset *pipeline.Asset, query string) (string, error) {
return "", fmt.Errorf("materialization strategy %s is not supported for materialization type %s", asset.Materialization.Strategy, asset.Materialization.Type)
return "", fmt.Errorf("materialization strategy %s is not supported for materialization type %s and asset type %s", asset.Materialization.Strategy, asset.Materialization.Type, asset.Type)
}

func viewMaterializer(asset *pipeline.Asset, query string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/materialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewMaterializer(fullRefresh bool) *pipeline.Materializer {
}

func errorMaterializer(asset *pipeline.Asset, query string) (string, error) {
return "", fmt.Errorf("materialization strategy %s is not supported for materialization type %s", asset.Materialization.Strategy, asset.Materialization.Type)
return "", fmt.Errorf("materialization strategy %s is not supported for materialization type %s and asset type %s", asset.Materialization.Strategy, asset.Materialization.Type, asset.Type)
}

func viewMaterializer(asset *pipeline.Asset, query string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/synapse/materialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var matMap = AssetMaterializationMap{
}

func errorMaterializer(asset *pipeline.Asset, _ string) ([]string, error) {
return []string{""}, fmt.Errorf("materialization strategy %s is not supported for materialization type %s", asset.Materialization.Strategy, asset.Materialization.Type)
return nil, fmt.Errorf("materialization strategy %s is not supported for materialization type %s and asset type %s", asset.Materialization.Strategy, asset.Materialization.Type, asset.Type)
}

func viewMaterializer(asset *pipeline.Asset, query string) ([]string, error) {
Expand Down

0 comments on commit 0ecd685

Please sign in to comment.