From 56984d04c2ada88be8c572412de48b6342bf2187 Mon Sep 17 00:00:00 2001 From: achettyiitr Date: Fri, 23 Aug 2024 15:09:32 +0530 Subject: [PATCH] chore: debug databricks logs for information schema columns --- sqlconnect/internal/databricks/db.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sqlconnect/internal/databricks/db.go b/sqlconnect/internal/databricks/db.go index 31ae96f..233a2fb 100644 --- a/sqlconnect/internal/databricks/db.go +++ b/sqlconnect/internal/databricks/db.go @@ -4,7 +4,10 @@ import ( "database/sql" "encoding/json" "fmt" + "log" + "os" "strings" + "time" databricks "github.com/databricks/databricks-sql-go" "github.com/samber/lo" @@ -60,9 +63,15 @@ func NewDB(configJson json.RawMessage) (*DB, error) { db := sql.OpenDB(connector) db.SetConnMaxIdleTime(config.MaxConnIdleTime) + l := log.New(os.Stdout, "databricks", log.LstdFlags) + + startTime := time.Now() + l.Println("Checking if information schema is available") if _, err = db.Exec("SELECT * FROM INFORMATION_SCHEMA.COLUMNS LIMIT 1"); err != nil && !strings.Contains(err.Error(), "TABLE_OR_VIEW_NOT_FOUND") { + l.Println("Error checking if information schema is available: ", err) return nil, fmt.Errorf("checking if unity catalog is available: %w", err) } + l.Println("Information schema is available: ", time.Since(startTime)) informationSchema := err == nil return &DB{