Skip to content

Commit 1644c21

Browse files
committed
dbqctl v0.4.0
1 parent f4a2ae0 commit 1644c21

File tree

7 files changed

+44
-37
lines changed

7 files changed

+44
-37
lines changed

checks.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ validations:
77
checks:
88
- id: row_count > 0
99
description: "data should be present" # optional
10-
on_fail: error # optional (error, warn), default "error"
10+
on_error: alert # optional (ignore, alert), default "alert"
1111

1212
- id: row_count between 100 and 30000
1313
description: "expected rows count"
14-
on_fail: warn
14+
on_error: ignore
1515

1616
- id: null_count(pickup_ntaname) == 0
1717
description: "no nulls are allowed in column: pickup_ntaname"
@@ -40,11 +40,11 @@ validations:
4040
checks:
4141
- id: row_count > 0
4242
description: "data should be present"
43-
on_fail: error
43+
on_error: alert
4444

4545
- id: row_count between 200000 and 300000
4646
description: "expected rows count"
47-
on_fail: warn
47+
on_error: ignore
4848

4949
- id: min(price) > 0
5050
description: "min(price) should be greater than zero"
@@ -60,7 +60,7 @@ validations:
6060
checks:
6161
- id: row_count > 0
6262
description: "data should be present"
63-
on_fail: error
63+
on_error: alert
6464

6565
- id: min(salary) > 0
6666
description: "min(salary) should be greater than zero"

cmd/check.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ package cmd
1616

1717
import (
1818
"fmt"
19-
"github.com/DataBridgeTech/dbqcore"
20-
"github.com/DataBridgeTech/dbqctl/internal"
2119
"log/slog"
2220
"os"
2321
"strings"
2422

23+
"github.com/DataBridgeTech/dbqcore"
24+
"github.com/DataBridgeTech/dbqctl/internal"
25+
2526
"github.com/spf13/cobra"
2627
)
2728

@@ -82,7 +83,7 @@ By automating these checks, you can proactively identify and address data qualit
8283
})
8384
}
8485

85-
if !pass && strGetOrDefault(string(check.OnFail), string(dbqcore.OnFailActionError)) == string(dbqcore.OnFailActionError) {
86+
if !pass && strGetOrDefault(string(check.OnError), string(dbqcore.OnErrorActionAlert)) == string(dbqcore.OnErrorActionAlert) {
8687
exitCode = 1
8788
}
8889
}

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
const (
25-
DbqCtlVersion = "v0.3.0"
25+
DbqCtlVersion = "v0.4.0"
2626
)
2727

2828
func NewVersionCommand() *cobra.Command {

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/DataBridgeTech/dbqctl
33
go 1.24.5
44

55
require (
6-
github.com/DataBridgeTech/dbqcore v0.3.0
6+
github.com/DataBridgeTech/dbqcore v0.4.0
77
github.com/spf13/cobra v1.9.1
88
github.com/spf13/pflag v1.0.7
99
github.com/spf13/viper v1.20.1
@@ -29,16 +29,16 @@ require (
2929
github.com/paulmach/orb v0.11.1 // indirect
3030
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
3131
github.com/pierrec/lz4/v4 v4.1.22 // indirect
32-
github.com/sagikazarmark/locafero v0.9.0 // indirect
32+
github.com/sagikazarmark/locafero v0.10.0 // indirect
3333
github.com/segmentio/asm v1.2.0 // indirect
3434
github.com/shopspring/decimal v1.4.0 // indirect
35-
github.com/sourcegraph/conc v0.3.0 // indirect
35+
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
3636
github.com/spf13/afero v1.14.0 // indirect
3737
github.com/spf13/cast v1.9.2 // indirect
3838
github.com/subosito/gotenv v1.6.0 // indirect
3939
go.opentelemetry.io/otel v1.37.0 // indirect
4040
go.opentelemetry.io/otel/trace v1.37.0 // indirect
4141
go.uber.org/multierr v1.11.0 // indirect
42-
golang.org/x/sys v0.34.0 // indirect
43-
golang.org/x/text v0.27.0 // indirect
42+
golang.org/x/sys v0.35.0 // indirect
43+
golang.org/x/text v0.28.0 // indirect
4444
)

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ github.com/ClickHouse/ch-go v0.67.0/go.mod h1:2MSAeyVmgt+9a2k2SQPPG1b4qbTPzdGDpf
55
github.com/ClickHouse/clickhouse-go/v2 v2.39.0 h1:spDlvQPW4d2EIOmzxeoRdeUPQ5j9zFryEx6L+XjfGoM=
66
github.com/ClickHouse/clickhouse-go/v2 v2.39.0/go.mod h1:m13KylpdcPzpIjznlfXp53IpdgZ7plTxOSCZnKphYZ8=
77
github.com/DataBridgeTech/dbqcore v0.3.0/go.mod h1:frSX2soCK0jiZMu1rcPPbvHar2KMtKL0/Hh2fHiQJ6s=
8+
github.com/DataBridgeTech/dbqcore v0.4.0 h1:GEoH9o6ByltB6VUil02Wu6/vA2qarVcFd7j18h5Eeiw=
9+
github.com/DataBridgeTech/dbqcore v0.4.0/go.mod h1:frSX2soCK0jiZMu1rcPPbvHar2KMtKL0/Hh2fHiQJ6s=
810
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
911
github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
1012
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
@@ -64,12 +66,16 @@ github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWN
6466
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
6567
github.com/sagikazarmark/locafero v0.9.0 h1:GbgQGNtTrEmddYDSAH9QLRyfAHY12md+8YFTqyMTC9k=
6668
github.com/sagikazarmark/locafero v0.9.0/go.mod h1:UBUyz37V+EdMS3hDF3QWIiVr/2dPrx49OMO0Bn0hJqk=
69+
github.com/sagikazarmark/locafero v0.10.0 h1:FM8Cv6j2KqIhM2ZK7HZjm4mpj9NBktLgowT1aN9q5Cc=
70+
github.com/sagikazarmark/locafero v0.10.0/go.mod h1:Ieo3EUsjifvQu4NZwV5sPd4dwvu0OCgEQV7vjc9yDjw=
6771
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
6872
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
6973
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
7074
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
7175
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
7276
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
77+
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw=
78+
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U=
7379
github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA=
7480
github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo=
7581
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
@@ -126,13 +132,17 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
126132
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
127133
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
128134
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
135+
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
136+
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
129137
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
130138
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
131139
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
132140
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
133141
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
134142
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
135143
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
144+
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
145+
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
136146
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
137147
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
138148
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=

internal/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (app *DbqAppImpl) ProfileDataset(srcId string, dataset string, sample bool,
9191
return nil, err
9292
}
9393

94-
return dbqProfiler.ProfileDataset(context.Background(), dataset, sample, maxConcurrent) // todo: ctx propagation
94+
return dbqProfiler.ProfileDataset(context.Background(), dataset, sample, maxConcurrent, true) // todo: ctx propagation
9595
}
9696

9797
func (app *DbqAppImpl) GetDbqConfig() *dbqcore.DbqConfig {

readme.md

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ Refer to [checks.yaml](./checks.yaml) example for full configuration overview.
7777
version: "1"
7878
validations:
7979
# https://clickhouse.com/docs/getting-started/example-datasets/nyc-taxi
80-
- dataset: ch@[nyc_taxi.trips_small]
80+
- dataset: ch@[nyc_taxi.trips_small, nyc_taxi.trips_full]
8181
# common pre-filter for every check, e.g. to run daily check only for yesterday
8282
where: "pickup_datetime > '2014-01-01'"
8383
checks:
8484
- id: row_count > 0
8585
description: "data should be present" # optional
86-
on_fail: error # optional (error, warn), default "error"
86+
on_error: alert # optional (ignore, alert), default "alert"
8787

8888
- id: row_count between 100 and 30000
8989
description: "expected rows count"
90-
on_fail: warn
90+
on_error: ignore
9191

9292
- id: null_count(pickup_ntaname) == 0
9393
description: "no nulls are allowed in column: pickup_ntaname"
@@ -108,35 +108,28 @@ validations:
108108
description: "raw query quality test"
109109
query: |
110110
select countIf(trip_distance == 0) > 0 from {{table}} where 1=1
111-
111+
112112
# https://wiki.postgresql.org/wiki/Sample_Databases
113113
- dataset: pg@[public.land_registry_price_paid_uk]
114114
# exclude January for example
115115
where: "transfer_date >= '2025-02-01 00:00:00.000000'"
116116
checks:
117117
- id: row_count > 0
118118
description: "data should be present"
119-
on_fail: error
120-
121-
- id: row_count between 200000 and 300000
122-
description: "expected rows count"
123-
on_fail: warn
124-
119+
on_error: alert
120+
125121
- id: min(price) > 0
126122
description: "min(price) should be greater than zero"
127-
123+
128124
- id: max(price) < 100000000
129125
description: "max(price) should be less than 100_000_000"
130-
131-
- id: stddev_pop(price) < 500000
132-
description: "price stddev"
133-
126+
134127
# https://github.com/datacharmer/test_db
135128
- dataset: mysql@[employees.salaries]
136129
checks:
137130
- id: row_count > 0
138131
description: "data should be present"
139-
on_fail: error
132+
on_error: alert
140133
```
141134
142135
### Commands
@@ -168,18 +161,21 @@ Use "dbqctl [command] --help" for more information about a command.
168161

169162
### Quick usage examples
170163
```bash
171-
# check connection to datasource
172-
$ dqbctl ping cnn-id
164+
# check connection for datasource
165+
$ dqbctl ping -d cnn-id
166+
167+
# check connection for all configured datasources
168+
$ dqbctl ping
173169

174170
# automatically import datasets from datasource with applied filter and in-place update config file
175-
$ dbqctl import cnn-id --filter "reporting.*" --cfg checks.yaml --update-cfg
171+
$ dbqctl import -d cnn-id --filter "reporting" --update-config
176172

177173
# run checks from checks.yaml file
178-
$ dbqctl check --checks checks.yaml
174+
$ dbqctl check --checks ./checks.yaml
179175

180176
# override default dbqctl config file
181177
$ dbqctl --config /path/to/dbq.yaml import
182178

183-
# run dataset profile to collect general stats
184-
$ dbqctl profile --datasource cnn-id --dataset table_name
179+
# run dataset profile to collect general stats (limit concurrent jobs to 8)
180+
$ dbqctl profile -d cnn-id --dataset table_name -j 8
185181
```

0 commit comments

Comments
 (0)