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

Commit 2fe17a1

Browse files
authored
Merge pull request #16 from datafold/databricks_3_part_id
Databricks: support 3 part id
2 parents f415f5a + 66d451c commit 2fe17a1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

sqeleton/databases/databricks.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ def query_table_schema(self, path: DbPath) -> Dict[str, tuple]:
128128

129129
conn = self.create_connection()
130130

131-
schema, table = self._normalize_table_path(path)
131+
catalog, schema, table = self._normalize_table_path(path)
132132
with conn.cursor() as cursor:
133-
cursor.columns(catalog_name=self.catalog, schema_name=schema, table_name=table)
133+
cursor.columns(catalog_name=catalog, schema_name=schema, table_name=table)
134134
try:
135135
rows = cursor.fetchall()
136136
finally:
@@ -185,3 +185,15 @@ def parse_table_name(self, name: str) -> DbPath:
185185
@property
186186
def is_autocommit(self) -> bool:
187187
return True
188+
189+
def _normalize_table_path(self, path: DbPath) -> DbPath:
190+
if len(path) == 1:
191+
return self.catalog, self.default_schema, path[0]
192+
elif len(path) == 2:
193+
return self.catalog, path[0], path[1]
194+
elif len(path) == 3:
195+
return path
196+
197+
raise ValueError(
198+
f"{self.name}: Bad table path for {self}: '{'.'.join(path)}'. Expected format: table, schema.table, or catalog.schema.table"
199+
)

0 commit comments

Comments
 (0)