Skip to content

Commit a118e43

Browse files
committed
fix cmd descriptions
1 parent 3c9c9c4 commit a118e43

12 files changed

Lines changed: 75 additions & 67 deletions

File tree

checks.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
version: 0.1
1+
version: "1"
22
validations:
3-
- dataset: clickhouse-prod-euw:ads.my_table_1
3+
- dataset: clickhouse-prod-euw@[ads.my_table_1]
4+
where: "timestamp > '2025-01-01'"
45
checks:
5-
- id: row number between 0 and 100
6-
severity: warn
6+
- id: row count between 0 and 100
7+
severity: error
78
type: row_count
89
params:
9-
filter: "timestamp > '2023-01-01'"
10+
# filter: "timestamp > '2023-01-01'"
1011
min: 0
1112
max: 100
1213

1314
- id: "no null values"
14-
description: "Check if table_1 has the correct number of columns"
15+
description: "Check if table_1 has the correct number of columns" # optional
1516
severity: error
1617
type: custom
1718
params:
18-
query: SELECT COUNT(*) FROM table_1 WHERE column_name IS NULL
19+
query: SELECT COUNT(*) FROM ${table} WHERE column_name IS NULL
1920
expected: 0
2021

2122
- id: "no duplicates"
@@ -24,7 +25,7 @@ validations:
2425
type: no_duplicates
2526
params:
2627
columns: ["column_1", "column_2"]
27-
filter: "timestamp > '2023-01-01'"
28+
# filter: "timestamp > '2023-01-01'"
2829

2930
- dataset: pgsql-staging@[public.table_1, public.table_2]
3031
checks:

cmd/check.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ func NewCheckCommand(app internal.DbqApp) *cobra.Command {
1313

1414
cmd := &cobra.Command{
1515
Use: "check",
16-
Short: "A brief description of your command",
17-
Long: `A longer description that spans multiple lines and likely contains examples
18-
and usage of using your command. For example:
16+
Short: "Runs data quality checks defined in a configuration file against a datasource",
17+
Long: `The 'check' command executes a series of data quality tests or checks as defined in a specified configuration file against a target dataset. This command reads the configuration file,
18+
which outlines the rules and constraints that the data within the dataset should adhere to. For each defined check, the command analyzes the dataset and reports any violations or inconsistencies found.
1919
20-
Cobra is a CLI library for Go that empowers applications.
21-
This application is a tool to generate the needed files
22-
to quickly create a Cobra application.`,
20+
By automating these checks, you can proactively identify and address data quality issues, ensuring that your datasets meet the required standards for analysis and decision-making.
21+
`,
2322
RunE: func(cmd *cobra.Command, args []string) error {
2423
fmt.Println("Reading checks from " + checksFile)
2524
if dataSource != "" {

cmd/import.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ func NewImportCommand(app internal.DbqApp) *cobra.Command {
1414

1515
cmd := &cobra.Command{
1616
Use: "import",
17-
Short: "A brief description of your command",
18-
Long: `A longer description that spans multiple lines and likely contains examples
19-
and usage of using your command. For example:
17+
Short: "Connects to a data source and imports all available tables as datasets",
18+
Long: `The 'import' command establishes a connection to the specified data source using the provided connection parameters. It retrieves a list of all available tables within the data source and transforms them into datasets within dbq.
2019
21-
Cobra is a CLI library for Go that empowers applications.
22-
This application is a tool to generate the needed files
23-
to quickly create a Cobra application.`,
20+
This command is useful for quickly onboarding data from external systems, allowing you to easily access and work with already existing data.
21+
`,
2422
RunE: func(cmd *cobra.Command, args []string) error {
2523
datasets, err := app.ImportDatasets(dataSource, filter)
2624
if err != nil {

cmd/ping.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,36 @@ package cmd
22

33
import (
44
"dbq/internal"
5-
"fmt"
65
"github.com/spf13/cobra"
6+
"log"
77
)
88

99
func NewPingCommand(app internal.DbqApp) *cobra.Command {
1010
var dataSource string
1111

1212
cmd := &cobra.Command{
1313
Use: "ping",
14-
Short: "A brief description of your command",
15-
Long: `A longer description that spans multiple lines and likely contains examples
16-
and usage of using your command. For example:
17-
18-
Cobra is a CLI library for Go that empowers applications.
19-
This application is a tool to generate the needed files
20-
to quickly create a Cobra application.`,
14+
Short: "Checks if the data source is reachable",
15+
Long: `The 'ping' command sends a network request to the configured data source to verify its reachability.
16+
This is useful for quickly determining if the data source is online and responding. It provides a simple status indication of the connection`,
2117
Run: func(cmd *cobra.Command, args []string) {
22-
err := app.PingDataSource(dataSource)
23-
if err != nil {
24-
fmt.Printf("Connection failed: %s\n", err.Error())
18+
var sourcesToPing []string
19+
if dataSource != "" {
20+
sourcesToPing = append(sourcesToPing, dataSource)
2521
} else {
26-
fmt.Println("Connection works")
22+
for _, ds := range app.GetDbqConfig().DataSources {
23+
sourcesToPing = append(sourcesToPing, ds.ID)
24+
}
25+
}
26+
27+
for _, curDataSource := range sourcesToPing {
28+
log.Printf("Pinging data source: %s...\n", curDataSource)
29+
info, err := app.PingDataSource(curDataSource)
30+
if err != nil {
31+
log.Printf("Connection failed: %s\n", err.Error())
32+
} else {
33+
log.Printf("Connected: %s\n", info)
34+
}
2735
}
2836
},
2937
}

cmd/profile.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ func NewProfileCommand(app internal.DbqApp) *cobra.Command {
1313

1414
cmd := &cobra.Command{
1515
Use: "profile",
16-
Short: "A brief description of your command",
17-
Long: `A longer description that spans multiple lines and likely contains examples
18-
and usage of using your command. For example:
16+
Short: "Collects dataset's information and generates column statistics",
17+
Long: `The 'profile' command connects to the specified data source and analyzes a given dataset. It gathers essential information about the table, such as the total number of rows.
18+
Additionally, for each column within the table, it calculates and reports various statistical metrics. These metrics may include the minimum value, maximum value, the count of null or missing values, the data type,
19+
and other relevant statistics depending on the data type and the capabilities of the underlying data source.
1920
20-
Cobra is a CLI library for Go that empowers applications.
21-
This application is a tool to generate the needed files
22-
to quickly create a Cobra application.`,
21+
This command is useful for understanding the characteristics and quality of your data. It provides a quick overview of the data distribution, identifies potential data quality issues like missing values,
22+
and helps in making better decisions about data processing and analysis.
23+
`,
2324
RunE: func(cmd *cobra.Command, args []string) error {
2425
var dataSetsToProfile []string
2526
if dataSet != "" {

cmd/root.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ import (
99

1010
var rootCmd = &cobra.Command{
1111
Use: "dbq",
12-
Short: "A brief description of your application",
13-
Long: `A longer description that spans multiple lines and likely contains
14-
examples and usage of using your application. For example:
15-
16-
Cobra is a CLI library for Go that empowers applications.
17-
This application is a tool to generate the needed files
18-
to quickly create a Cobra application.`,
12+
Short: "dbq is a CLI tool for profiling data and running quality checks across various data sources",
1913
}
2014

2115
func Execute() {

cmd/version.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ import (
88
func NewVersionCommand() *cobra.Command {
99
cmd := &cobra.Command{
1010
Use: "version",
11-
Short: "A brief description of your command",
12-
Long: `A longer description that spans multiple lines and likely contains examples
13-
and usage of using your command. For example:
14-
15-
Cobra is a CLI library for Go that empowers applications.
16-
This application is a tool to generate the needed files
17-
to quickly create a Cobra application.`,
11+
Short: "Prints dbq version",
1812
Run: func(cmd *cobra.Command, args []string) {
1913
fmt.Println("DataBridge Quality Core: 0.0.1")
2014
},

dbq.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ datasources:
1111
datasets:
1212
- default.my_first_table
1313
- default.trips_small
14+
- uk.uk_price_paid
1415
- id: pgsql
1516
type: postgres
1617
configuration:

internal/app.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import (
66
"github.com/spf13/cobra"
77
"github.com/spf13/viper"
88
"gopkg.in/yaml.v3"
9-
"log"
109
"os"
1110
"strings"
1211
)
1312

1413
type DbqApp interface {
15-
PingDataSource(srcId string) error
14+
PingDataSource(srcId string) (string, error)
1615
ImportDatasets(srcId string, filter string) ([]string, error)
1716
ProfileDataSourceById(srcId string, dataset string) (*TableMetrics, error)
1817
GetDbqConfig() *DbqConfig
@@ -33,21 +32,20 @@ func NewDbqApp(dbqConfigPath string) DbqApp {
3332
}
3433
}
3534

36-
func (app *DbqAppImpl) PingDataSource(srcId string) error {
35+
func (app *DbqAppImpl) PingDataSource(srcId string) (string, error) {
3736
var dataSource = app.FindDataSourceById(srcId)
3837

3938
cnn, err := getDbqConnector(*dataSource)
4039
if err != nil {
41-
return err
40+
return "", err
4241
}
4342

44-
log.Println("Pinging datasource: " + dataSource.ID)
45-
err = cnn.Ping()
43+
info, err := cnn.Ping()
4644
if err != nil {
47-
return err
45+
return "", err
4846
}
4947

50-
return nil
48+
return info, nil
5149
}
5250

5351
func (app *DbqAppImpl) ImportDatasets(srcId string, filter string) ([]string, error) {

internal/clickhouse.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,18 @@ func NewClickhouseDbqConnector(dataSource DataSource) (DbqConnector, error) {
3333
}, err
3434
}
3535

36-
func (c *ClickhouseDbqConnector) Ping() error {
37-
return c.cnn.Ping(context.Background())
36+
func (c *ClickhouseDbqConnector) Ping() (string, error) {
37+
err := c.cnn.Ping(context.Background())
38+
if err != nil {
39+
return "", err
40+
}
41+
42+
info, err := c.cnn.ServerVersion()
43+
if err != nil {
44+
return "", err
45+
}
46+
47+
return info.String(), nil
3848
}
3949

4050
func (c *ClickhouseDbqConnector) ImportDataSets(filter string) ([]string, error) {

0 commit comments

Comments
 (0)