@@ -26,8 +26,9 @@ import (
2626)
2727
2828type FailedCheckDetails struct {
29- ID string
30- Err error
29+ ID string
30+ Dataset string
31+ Err error
3132}
3233
3334func NewCheckCommand (app internal.DbqCliApp ) * cobra.Command {
@@ -51,6 +52,9 @@ By automating these checks, you can proactively identify and address data qualit
5152 }
5253
5354 exitCode := 0
55+ passedCount := 0
56+ var failedChecks []FailedCheckDetails
57+
5458 for _ , rule := range checksCfg .Validations {
5559 dataSourceId , datasets , err := parseDatasetString (rule .Dataset )
5660 if err != nil {
@@ -62,35 +66,42 @@ By automating these checks, you can proactively identify and address data qualit
6266 return fmt .Errorf ("specified data source not found in dbq configuration: %s" , dataSourceId )
6367 }
6468
65- var failedChecks []FailedCheckDetails
6669 for _ , dataset := range datasets {
6770 fmt .Printf ("running %d quality checks for '%s'\n " , len (rule .Checks ), dataset )
6871 for _ , check := range rule .Checks {
69- pass , _ , _ := app .RunCheck (& check , dataSource , dataset , rule .Where )
70- fmt .Printf (" check %s ('%s') ... %s\n " , check .Description , check .ID , getCheckResultLabel (pass ))
71-
72- if err != nil {
73- failedChecks = append (failedChecks , FailedCheckDetails {ID : check .ID , Err : err })
72+ pass , _ , err := app .RunCheck (& check , dataSource , dataset , rule .Where )
73+
74+ fmt .Printf (" check %s ... %s\n " , check .Description , getCheckResultLabel (pass ))
75+ if err == nil {
76+ passedCount += 1
77+ } else {
78+ failedChecks = append (failedChecks , FailedCheckDetails {
79+ ID : check .ID ,
80+ Dataset : dataset ,
81+ Err : err ,
82+ })
7483 }
7584
7685 if ! pass && strGetOrDefault (string (check .OnFail ), dbqcore .OnFailActionError ) == dbqcore .OnFailActionError {
7786 exitCode = 1
7887 }
7988 }
8089 }
90+ }
8191
82- if len (failedChecks ) != 0 {
83- for _ , result := range failedChecks {
84- fmt .Println ()
85- fmt .Printf ("--- %s ---\n " , result .ID )
86- fmt .Printf ("error: %s\n " , result .Err )
87- }
92+ if len (failedChecks ) != 0 {
93+ for _ , result := range failedChecks {
94+ fmt .Println ()
95+ fmt .Printf ("--- %s ---\n " , result .ID )
96+ fmt .Printf ("error: %s\n " , result .Err )
8897 }
8998 }
9099
100+ fmt .Println ()
101+ failedCount := len (failedChecks )
102+ fmt .Printf ("\n check result: %s. %d passed; %d failed; \n " , getCheckResultLabel (failedCount == 0 ), passedCount , failedCount )
103+
91104 if exitCode != 0 {
92- // todo: print detailed report
93- // fmt.Printf("\ncheck result: FAILED. 1 passed; 1 failed; \n")
94105 os .Exit (exitCode )
95106 }
96107
0 commit comments