11package internal
22
33import (
4- "errors"
54 "fmt"
65 "github.com/spf13/cobra"
76 "github.com/spf13/viper"
@@ -13,7 +12,7 @@ import (
1312type DbqApp interface {
1413 PingDataSource (srcId string ) (string , error )
1514 ImportDatasets (srcId string , filter string ) ([]string , error )
16- ProfileDataSourceById (srcId string , dataset string ) (* TableMetrics , error )
15+ ProfileDataset (srcId string , dataset string ) (* TableMetrics , error )
1716 GetDbqConfig () * DbqConfig
1817 SaveDbqConfig () error
1918 FindDataSourceById (srcId string ) * DataSource
@@ -26,9 +25,9 @@ type DbqAppImpl struct {
2625}
2726
2827func NewDbqApp (dbqConfigPath string ) DbqApp {
29- dbqConfig := initConfig (dbqConfigPath )
28+ dbqConfig , dbqConfigUsedPath := initConfig (dbqConfigPath )
3029 return & DbqAppImpl {
31- dbqConfigPath : dbqConfigPath ,
30+ dbqConfigPath : dbqConfigUsedPath ,
3231 dbqConfig : dbqConfig ,
3332 }
3433}
@@ -56,16 +55,16 @@ func (app *DbqAppImpl) ImportDatasets(srcId string, filter string) ([]string, er
5655 return []string {}, err
5756 }
5857
59- return cnn .ImportDataSets (filter )
58+ return cnn .ImportDatasets (filter )
6059}
6160
62- func (app * DbqAppImpl ) ProfileDataSourceById (srcId string , dataset string ) (* TableMetrics , error ) {
61+ func (app * DbqAppImpl ) ProfileDataset (srcId string , dataset string ) (* TableMetrics , error ) {
6362 var dataSource = app .FindDataSourceById (srcId )
6463 cnn , err := getDbqConnector (* dataSource )
6564 if err != nil {
6665 return nil , err
6766 }
68- return cnn .ProfileDataSet (dataset )
67+ return cnn .ProfileDataset (dataset )
6968}
7069
7170func (app * DbqAppImpl ) GetDbqConfig () * DbqConfig {
@@ -103,7 +102,7 @@ func (app *DbqAppImpl) RunCheck(check *Check, dataSource *DataSource, dataSet st
103102 return cnn .RunCheck (check , dataSet , defaultWhere )
104103}
105104
106- func initConfig (dbqConfigPath string ) * DbqConfig {
105+ func initConfig (dbqConfigPath string ) ( * DbqConfig , string ) {
107106 v := viper .New ()
108107
109108 if dbqConfigPath != "" {
@@ -126,7 +125,7 @@ func initConfig(dbqConfigPath string) *DbqConfig {
126125 cobra .CheckErr (err )
127126 }
128127
129- return & dbqConfig
128+ return & dbqConfig , v . ConfigFileUsed ()
130129}
131130
132131func getDbqConnector (ds DataSource ) (DbqConnector , error ) {
@@ -135,6 +134,6 @@ func getDbqConnector(ds DataSource) (DbqConnector, error) {
135134 case "clickhouse" :
136135 return NewClickhouseDbqConnector (ds )
137136 default :
138- return nil , errors . New ( fmt .Sprintf ( "Data source type '%s' is not supported. " , dsType ) )
137+ return nil , fmt .Errorf ( "data source type '%s' is not supported" , dsType )
139138 }
140139}
0 commit comments