dburl
dburl copied to clipboard
GenDatabricks produces incorrect DSN values
The DSN generator for databricks is producing very strange results (https://github.com/xo/dburl/blob/master/dsn.go#L223-L241)
When digging into the code:
s := fmt.Sprintf("token:%s@%s.databricks.com:%s/sql/1.0/endpoints/%s", user, pass, port, host)
- The username (
token) is being put into the password - The password is then being put into the URL (this immediately creates a leak of the password in logs)
- The port is correct 🎉
- The host is then appended onto the end of the path
- Host like this also prevents other types of clusters from being used
Ideally this should be updated to the following:
s := fmt.Sprintf("token:%s@%s:%s%s", pass, host, port, path)
To get around this issue for the moment I am doing the following with the uri dburl.URL value:
sql.Open("databricks", fmt.Sprintf("%s@%s%s?%s", uri.User, uri.Host, uri.Path, uri.RawQuery))
@jbeemster Databricks just doesn't work properly with dburl, due to how it connects to its databases. If you want to submit a PR to change this, that's fine. It was mostly added simply because it needed to be in dburl so that the corresponding Databricks driver in usql would work. As it is with usql, you have to basically create the connection manually in order to connect.