Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 963eba8

Browse files
committed
Fix databricks URI to databricks://:access_token@server_name/http_path
1 parent 66b7e52 commit 963eba8

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

data_diff/databases/connect.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def match_path(self, dsn):
7979
"presto": MatchUriPath(Presto, ["catalog", "schema"], help_str="presto://<user>@<host>/<catalog>/<schema>"),
8080
"bigquery": MatchUriPath(BigQuery, ["dataset"], help_str="bigquery://<project>/<dataset>"),
8181
"databricks": MatchUriPath(
82-
Databricks, ["catalog", "schema"], help_str="databricks://http_path:access_token@server_name/catalog/schema",
82+
Databricks, ["catalog", "schema"], help_str="databricks://:access_token@server_name/http_path",
8383
)
8484
}
8585

@@ -118,29 +118,33 @@ def connect_to_uri(db_uri: str, thread_count: Optional[int] = 1) -> Database:
118118
raise NotImplementedError(f"Scheme {scheme} currently not supported")
119119

120120
cls = matcher.database_cls
121-
kw = matcher.match_path(dsn)
122121

123-
if scheme == "bigquery":
124-
kw["project"] = dsn.host
125-
return cls(**kw)
126-
127-
if scheme == "snowflake":
128-
kw["account"] = dsn.host
129-
assert not dsn.port
130-
kw["user"] = dsn.user
131-
kw["password"] = dsn.password
132122
if scheme == "databricks":
133-
# dsn user - access token
134-
# sdn password - http path (starting with /)
135-
kw["http_path"] = dsn.user
136-
kw["access_token"] = dsn.password
137-
kw["server_hostname"] = dsn.host
123+
assert not dsn.user
124+
kw = {}
125+
kw['access_token'] = dsn.password
126+
kw['http_path'] = dsn.path
127+
kw['server_hostname'] = dsn.host
128+
kw.update(dsn.query)
138129
else:
139-
kw["host"] = dsn.host
140-
kw["port"] = dsn.port
141-
kw["user"] = dsn.user
142-
if dsn.password:
130+
kw = matcher.match_path(dsn)
131+
132+
if scheme == "bigquery":
133+
kw["project"] = dsn.host
134+
return cls(**kw)
135+
136+
if scheme == "snowflake":
137+
kw["account"] = dsn.host
138+
assert not dsn.port
139+
kw["user"] = dsn.user
143140
kw["password"] = dsn.password
141+
else:
142+
kw["host"] = dsn.host
143+
kw["port"] = dsn.port
144+
kw["user"] = dsn.user
145+
if dsn.password:
146+
kw["password"] = dsn.password
147+
144148
kw = {k: v for k, v in kw.items() if v is not None}
145149

146150
if issubclass(cls, ThreadedDatabase):

0 commit comments

Comments
 (0)