Skip to content

Commit

Permalink
DRAFT: This scaffolds in the code for running parallel dialect compli…
Browse files Browse the repository at this point in the history
…ance

tests. Setting this up isn't documented anywhere and the implementation here
doesn't actually work because the test runner keeps trying to create
tables within the catalog.schema in the connection string.

Need to research more about why this happens. But wanted to stash this code
for now as we'll want to address this for faster compliance test runs
in the future.

Signed-off-by: Jesse Whitehouse <[email protected]>
  • Loading branch information
Jesse Whitehouse committed Oct 8, 2023
1 parent 214523b commit 7b7fe82
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/databricks/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,13 @@ def get_schema_names(self, connection, **kw):

# TODO: replace with call to cursor.schemas() once its performance matches raw SQL
return [row[0] for row in connection.execute("SHOW SCHEMAS")]

@classmethod
def load_provisioning(cls):
try:
__import__("databricks.sqlalchemy.provision")
except ImportError:
pass


@event.listens_for(Engine, "do_connect")
Expand Down
12 changes: 12 additions & 0 deletions src/databricks/sqlalchemy/provision.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from sqlalchemy.testing.provision import create_db, drop_db

@create_db.for_db("databricks")
def _databricks_create_db(cfg, eng, ident):
with eng.begin() as conn:
create_string = "CREATE SCHEMA `main`.`%s`" % ident
conn.exec_driver_sql(create_string)

@drop_db.for_db("databricks")
def _databricks_drop_db(cfg, eng, ident):
with eng.begin() as conn:
conn.exec_driver_sql("DROP SCHEMA `main`.`%s`" % ident)
3 changes: 3 additions & 0 deletions src/databricks/sqlalchemy/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
[sqla_testing]
requirement_cls=databricks.sqlalchemy.requirements:Requirements
profile_file=profiles.txt

[db]
databricks=<enter valid connection string here>

0 comments on commit 7b7fe82

Please sign in to comment.