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

Commit f577dc0

Browse files
committed
Update databricks URI and tests
1 parent 1bfe5d5 commit f577dc0

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ $ data-diff \
125125
| BigQuery | `bigquery://<project>/<dataset>` | 💛 |
126126
| Redshift | `redshift://<username>:<password>@<hostname>:5439/<database>` | 💛 |
127127
| Presto | `presto://<username>:<password>@<hostname>:8080/<database>` | 💛 |
128-
| Databricks | `databricks://<access_token>:<http_path>@<server_hostname>/<catalog>/<schema>` | 💛 |
128+
| Databricks | `databricks://<http_path>:<access_token>@<server_hostname>/<catalog>/<schema>` | 💛 |
129129
| ElasticSearch | | 📝 | | 📝 |
130130
| Planetscale | | 📝 |
131131
| Clickhouse | | 📝 |

data_diff/databases/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
from .bigquery import BigQuery
88
from .redshift import Redshift
99
from .presto import Presto
10+
from .databricks import Databricks
1011

1112
from .connect import connect_to_uri

data_diff/databases/connect.py

Lines changed: 7 additions & 7 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://access_token:http_path@account/catalog/schema"
82+
Databricks, ["catalog", "schema"], help_str="databricks://http_path:access_token@server_name/catalog/schema",
8383
)
8484
}
8585

@@ -129,6 +129,12 @@ def connect_to_uri(db_uri: str, thread_count: Optional[int] = 1) -> Database:
129129
assert not dsn.port
130130
kw["user"] = dsn.user
131131
kw["password"] = dsn.password
132+
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
132138
else:
133139
kw["host"] = dsn.host
134140
kw["port"] = dsn.port
@@ -137,12 +143,6 @@ def connect_to_uri(db_uri: str, thread_count: Optional[int] = 1) -> Database:
137143
kw["password"] = dsn.password
138144
kw = {k: v for k, v in kw.items() if v is not None}
139145

140-
if scheme == "databricks":
141-
# dsn user - access token
142-
# sdn password - http path (starting with /)
143-
144-
return cls(http_path=dsn.password, access_token=dsn.user, server_hostname=dsn.hostname, **kw)
145-
146146
if issubclass(cls, ThreadedDatabase):
147147
return cls(thread_count=thread_count, **kw)
148148

tests/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
TEST_BIGQUERY_CONN_STRING: str = None
1616
TEST_REDSHIFT_CONN_STRING: str = None
1717
TEST_ORACLE_CONN_STRING: str = None
18+
TEST_DATABRICKS_CONN_STRING: str = None
1819

1920
DEFAULT_N_SAMPLES = 50
2021
N_SAMPLES = int(os.environ.get("N_SAMPLES", DEFAULT_N_SAMPLES))
@@ -53,6 +54,7 @@ def get_git_revision_short_hash() -> str:
5354
db.Redshift: TEST_REDSHIFT_CONN_STRING,
5455
db.Oracle: TEST_ORACLE_CONN_STRING,
5556
db.Presto: TEST_PRESTO_CONN_STRING,
57+
db.Databricks: TEST_DATABRICKS_CONN_STRING,
5658
}
5759

5860
for k, v in CONN_STRINGS.items():

tests/test_database_types.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,23 @@ def __iter__(self):
350350
"char(100)",
351351
],
352352
},
353+
db.Databricks: {
354+
"int": [
355+
"INT",
356+
"BIGINT",
357+
],
358+
"datetime": [
359+
"TIMESTAMP",
360+
],
361+
"float": [
362+
"FLOAT",
363+
"DOUBLE",
364+
"DECIMAL(6, 2)",
365+
],
366+
"uuid": [
367+
"STRING",
368+
]
369+
}
353370
}
354371

355372

0 commit comments

Comments
 (0)