Skip to content

Commit aa5ca0a

Browse files
committed
licences and some yak shaving
1 parent 407b887 commit aa5ca0a

13 files changed

Lines changed: 145 additions & 36 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release dbq
1+
name: Release dbqctl
22

33
on:
44
push:
@@ -7,7 +7,7 @@ on:
77
- 'v*.*.*'
88

99
env:
10-
APP_NAME: dbq
10+
APP_NAME: dbqctl
1111
MAIN_PACKAGE_PATH: .
1212

1313
permissions:

cmd/check.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
1+
// Copyright 2025 The DBQ Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (
418
"fmt"
519
"github.com/DataBridgeTech/dbqcore"
20+
"github.com/DataBridgeTech/dbqctl/internal"
621
"log"
722
"os"
823
"strings"
924

10-
"github.com/DataBridgeTech/dbq/internal"
1125
"github.com/spf13/cobra"
1226
)
1327

@@ -51,7 +65,7 @@ By automating these checks, you can proactively identify and address data qualit
5165
}
5266

5367
log.Printf(" [%d/%d] '%s': %s", cIdx+1, len(rule.Checks), check.ID, getCheckResultLabel(pass))
54-
if !pass && internal.IdOrDefault(string(check.OnFail), dbqcore.OnFailActionError) == dbqcore.OnFailActionError {
68+
if !pass && strGetOrDefault(string(check.OnFail), dbqcore.OnFailActionError) == dbqcore.OnFailActionError {
5569
exitCode = 1
5670
}
5771
}
@@ -115,3 +129,10 @@ func getCheckResultLabel(passed bool) string {
115129
return "failed"
116130
}
117131
}
132+
133+
func strGetOrDefault(original string, defaultVal string) string {
134+
if original == "" {
135+
return defaultVal
136+
}
137+
return original
138+
}

cmd/import.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
// Copyright 2025 The DBQ Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (
418
"log"
519

6-
"github.com/DataBridgeTech/dbq/internal"
20+
"github.com/DataBridgeTech/dbqctl/internal"
721
"github.com/spf13/cobra"
822
)
923

cmd/ping.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
// Copyright 2025 The DBQ Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (
418
"log"
519

6-
"github.com/DataBridgeTech/dbq/internal"
20+
"github.com/DataBridgeTech/dbqctl/internal"
721
"github.com/spf13/cobra"
822
)
923

cmd/profile.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1+
// Copyright 2025 The DBQ Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (
418
"encoding/json"
5-
"github.com/DataBridgeTech/dbqcore"
619
"log"
720

8-
"github.com/DataBridgeTech/dbq/internal"
21+
"github.com/DataBridgeTech/dbqcore"
22+
"github.com/DataBridgeTech/dbqctl/internal"
923
"github.com/spf13/cobra"
1024
)
1125

cmd/root.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1+
// Copyright 2025 The DBQ Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (
418
"log/slog"
519
"os"
620

7-
"github.com/DataBridgeTech/dbq/internal"
21+
"github.com/DataBridgeTech/dbqctl/internal"
822
"github.com/spf13/cobra"
923
)
1024

cmd/version.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 The DBQ Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (
@@ -8,16 +22,16 @@ import (
822
)
923

1024
const (
11-
DbqVersion = "v0.0.4"
25+
DbqCtlVersion = "v0.0.4"
1226
)
1327

1428
func NewVersionCommand() *cobra.Command {
1529
cmd := &cobra.Command{
1630
Use: "version",
1731
Short: "Prints dbq version",
1832
Run: func(cmd *cobra.Command, args []string) {
19-
fmt.Printf("DataBridge Quality Core: %s\n", DbqVersion)
20-
fmt.Printf("DataBridge Lib Core: %s\n", dbqcore.GetDbqVersion())
33+
fmt.Printf("DataBridge Quality CLI: %s\n", DbqCtlVersion)
34+
fmt.Printf("DataBridge dbqcore lib version: %s\n", dbqcore.GetDbqCoreLibVersion())
2135
},
2236
}
2337

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module github.com/DataBridgeTech/dbq
1+
module github.com/DataBridgeTech/dbqctl
22

33
go 1.24.2
44

55
require (
6-
github.com/ClickHouse/clickhouse-go/v2 v2.34.0
76
github.com/DataBridgeTech/dbqcore v0.0.1
87
github.com/spf13/cobra v1.9.1
8+
github.com/spf13/pflag v1.0.6
99
github.com/spf13/viper v1.20.1
1010
gopkg.in/yaml.v3 v3.0.1
1111
)
@@ -14,6 +14,7 @@ require (
1414

1515
require (
1616
github.com/ClickHouse/ch-go v0.65.1 // indirect
17+
github.com/ClickHouse/clickhouse-go/v2 v2.34.0 // indirect
1718
github.com/andybalholm/brotli v1.1.1 // indirect
1819
github.com/fsnotify/fsnotify v1.8.0 // indirect
1920
github.com/go-faster/city v1.0.1 // indirect
@@ -31,7 +32,6 @@ require (
3132
github.com/sourcegraph/conc v0.3.0 // indirect
3233
github.com/spf13/afero v1.12.0 // indirect
3334
github.com/spf13/cast v1.7.1 // indirect
34-
github.com/spf13/pflag v1.0.6 // indirect
3535
github.com/subosito/gotenv v1.6.0 // indirect
3636
go.opentelemetry.io/otel v1.35.0 // indirect
3737
go.opentelemetry.io/otel/trace v1.35.0 // indirect

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ github.com/ClickHouse/ch-go v0.65.1 h1:SLuxmLl5Mjj44/XbINsK2HFvzqup0s6rwKLFH347Z
22
github.com/ClickHouse/ch-go v0.65.1/go.mod h1:bsodgURwmrkvkBe5jw1qnGDgyITsYErfONKAHn05nv4=
33
github.com/ClickHouse/clickhouse-go/v2 v2.34.0 h1:Y4rqkdrRHgExvC4o/NTbLdY5LFQ3LHS77/RNFxFX3Co=
44
github.com/ClickHouse/clickhouse-go/v2 v2.34.0/go.mod h1:yioSINoRLVZkLyDzdMXPLRIqhDvel8iLBlwh6Iefso8=
5+
github.com/DataBridgeTech/dbqcore v0.0.1 h1:ETqX/RXUDvD1XtK3Ld0DUZyxfweWbxDNA3Qgu/0cVgg=
6+
github.com/DataBridgeTech/dbqcore v0.0.1/go.mod h1:U2++eavpf8oSKxukSEJpKGfPaOtkApA7AUpzwkrXmVM=
57
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
68
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
79
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
@@ -32,8 +34,6 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf
3234
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
3335
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
3436
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
35-
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
36-
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
3737
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
3838
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
3939
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@@ -118,8 +118,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
118118
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
119119
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
120120
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
121-
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
122-
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
123121
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
124122
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
125123
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

internal/app.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 The DBQ Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package internal
216

317
import (
@@ -17,11 +31,11 @@ type DbqCliApp interface {
1731
PingDataSource(srcId string) (string, error)
1832
ImportDatasets(srcId string, filter string) ([]string, error)
1933
ProfileDataset(srcId string, dataset string, sample bool) (*dbqcore.TableMetrics, error)
34+
RunCheck(check *dbqcore.Check, dataSource *dbqcore.DataSource, dataset string, defaultWhere string) (bool, string, error)
2035
GetDbqConfig() *dbqcore.DbqConfig
2136
SaveDbqConfig() error
22-
FindDataSourceById(srcId string) *dbqcore.DataSource
23-
RunCheck(check *dbqcore.Check, dataSource *dbqcore.DataSource, dataset string, defaultWhere string) (bool, string, error)
2437
SetLogLevel(level slog.Level)
38+
FindDataSourceById(srcId string) *dbqcore.DataSource
2539
}
2640

2741
type DbqAppImpl struct {
@@ -57,6 +71,7 @@ func (app *DbqAppImpl) PingDataSource(srcId string) (string, error) {
5771

5872
func (app *DbqAppImpl) ImportDatasets(srcId string, filter string) ([]string, error) {
5973
var dataSource = app.FindDataSourceById(srcId)
74+
6075
cnn, err := getDbqConnector(*dataSource)
6176
if err != nil {
6277
return []string{}, err
@@ -67,10 +82,12 @@ func (app *DbqAppImpl) ImportDatasets(srcId string, filter string) ([]string, er
6782

6883
func (app *DbqAppImpl) ProfileDataset(srcId string, dataset string, sample bool) (*dbqcore.TableMetrics, error) {
6984
var dataSource = app.FindDataSourceById(srcId)
85+
7086
cnn, err := getDbqConnector(*dataSource)
7187
if err != nil {
7288
return nil, err
7389
}
90+
7491
return cnn.ProfileDataset(dataset, sample)
7592
}
7693

0 commit comments

Comments
 (0)