diff --git a/fetch_dbt_profiles.go b/fetch_dbt_profiles.go index 28fd197..155148f 100644 --- a/fetch_dbt_profiles.go +++ b/fetch_dbt_profiles.go @@ -11,17 +11,69 @@ import ( type DbtProfile struct { Target string `yaml:"target"` Outputs map[string]struct { - ConnType string `yaml:"type"` - Account string `yaml:"account"` - User string `yaml:"user"` - Role string `yaml:"role"` - Authenticator string `yaml:"authenticator"` - Database string `yaml:"database"` - Schema string `yaml:"schema"` - Project string `yaml:"project"` - Dataset string `yaml:"dataset"` - Path string `yaml:"path"` - Threads int `yaml:"threads"` + ConnType string `yaml:"type"` + Account string `yaml:"account"` + User string `yaml:"user"` + Role string `yaml:"role"` + Authenticator string `yaml:"authenticator"` + Database string `yaml:"database"` + Schema string `yaml:"schema"` + Project string `yaml:"project"` + Dataset string `yaml:"dataset"` + Path string `yaml:"path"` + Threads int `yaml:"threads"` + Password string `yaml:"password"` + Port int `yaml:"port"` + Warehouse string `yaml:"warehouse"` + Method string `yaml:"method"` + Host string `yaml:"host"` + PrivateKey string `yaml:"private_key"` + PrivateKeyPath string `yaml:"private_key_path"` + PrivateKeyPassphrase string `yaml:"private_key_passphrase"` + ClientSessionKeepAlive bool `yaml:"client_session_keep_alive"` + QueryTag string `yaml:"query_tag"` + ConnectRetries int `yaml:"connect_retries"` + ConnectTimeout int `yaml:"connect_timeout"` + RetryOnDatabaseErrors bool `yaml:"retry_on_database_errors"` + RetryAll bool `yaml:"retry_all"` + ReuseConnections bool `yaml:"reuse_connections"` + Extensions []string `yaml:"extensions"` + RefreshToken string `yaml:"refresh_token"` + ClientID string `yaml:"client_id"` + ClientSecret string `yaml:"client_secret"` + TokenURI string `yaml:"token_uri"` + Token string `yaml:"token"` + Priority string `yaml:"priority"` + Keyfile string `yaml:"keyfile"` + JobExecutionTimeoutSeconds int `yaml:"job_execution_timeout_seconds"` + JobCreationTimeoutSeconds int `yaml:"job_creation_timeout_seconds"` + JobRetryDeadlineSeconds int `yaml:"job_retry_deadline_seconds"` + Location string `yaml:"location"` + MaximumBytesBilled int `yaml:"maximum_bytes_billed"` + Scopes []string `yaml:"scopes"` + ImpersonateServiceAccount string `yaml:"impersonate_service_account"` + ExecutionProject string `yaml:"execution_project"` + GcsBucket string `yaml:"gcs_bucket"` + DataprocRegion string `yaml:"dataproc_region"` + DataprocClusterName string `yaml:"dataproc_cluster_name"` + DataprocBatch map[string]interface{} `yaml:"dataproc_batch"` + KeyfileJson map[string]struct { + Type string `yaml:"type"` + ProjectId string `yaml:"project_id"` + PrivateKeyId string `yaml:"private_key_id"` + PrivateKey string `yaml:"private_key"` + ClientEmail string `yaml:"client_email"` + ClientId string `yaml:"client_id"` + AuthURI string `yaml:"auth_uri"` + TokenURI string `yaml:"token_uri"` + AuthProviderX509CertUrl string `yaml:"auth_provider_x509_cert_url"` + ClientX509CertUrl string `yaml:"client_x509_cert_url"` + } `yaml:"keyfile_json"` + Settings map[string]struct { + S3Region string `yaml:"s3_region"` + S3AccessKeyID string `yaml:"s3_access_key_id"` + S3SecretAccessKey string `yaml:"s3_secret_access_key"` + } `yaml:"settings"` } `yaml:"outputs"` } diff --git a/set_connection_details.go b/set_connection_details.go index dbddd75..431557d 100644 --- a/set_connection_details.go +++ b/set_connection_details.go @@ -76,7 +76,12 @@ func SetConnectionDetails(fr FormResponse, ps DbtProfiles) shared.ConnectionDeta { cd = shared.ConnectionDetails{ ConnType: fr.Warehouse, - Path: filepath.Join(wd, fr.Path), + Path: func() string { + if fr.Path == "md:" { + return "md:" + } + return filepath.Join(wd, fr.Path) + }(), Database: fr.Database, Schema: fr.Schema, } diff --git a/sourcerer/connect_to_db.go b/sourcerer/connect_to_db.go index 710e187..c620e8d 100644 --- a/sourcerer/connect_to_db.go +++ b/sourcerer/connect_to_db.go @@ -44,6 +44,13 @@ func (bqc *BqConn) ConnectToDb(ctx context.Context) (err error) { func (dc *DuckConn) ConnectToDb(ctx context.Context) (err error) { _, dc.Cancel = context.WithTimeout(ctx, 1*time.Minute) defer dc.Cancel() + if dc.Path == "md:" { + dc.Db, err = sql.Open("duckdb", "md:") + if err != nil { + log.Fatalf("Could not connect to DuckDB %v\n", err) + } + return err + } if _, err := os.Stat(dc.Path); os.IsNotExist(err) { log.Fatalf("Path does not exist: %v\n", err) } diff --git a/version.go b/version.go index 622cc89..bc06758 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package main -const Version = "0.0.19" +const Version = "0.0.20"