-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(dbt): Instruct users of missing dependency when creating a Snowflake virtual dataset #290
Conversation
if dialect == "snowflake": | ||
raise CLIError( | ||
( | ||
"Missing required package. " | ||
'Please run ``pip install "preset-cli[snowflake]"`` to install it.' | ||
), | ||
1, | ||
) from exc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future this could be something like:
if dialect in {"snowflake", "redshift", "bigquery"}:
raise CLIError(
(
"Missing required package. "
f'Please run ``pip install "preset-cli[{dialect}]"`` to install it.'
),
1,
) from exc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Left a few comments.
@@ -198,6 +201,31 @@ def build_snowflake_sqlalchemy_params(target: Dict[str, Any]) -> Dict[str, Any]: | |||
return parameters | |||
|
|||
|
|||
def create_sqlalchemy_engine(url: URL): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def create_sqlalchemy_engine(url: URL): | |
def create_sqlalchemy_engine(url: URL) -> Engine: |
With:
from sqlalchemy.engine import Engine
Also, maybe we should rename this to create_engine_with_check
or something more explicit? To make it clear how it's different from create_engine
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch! and great idea!
dbt is compatible with warehouses that support creating multiple DBs in the same instance (such as Snowflake). Since the
database
is specified in the DB connection string in Superset, when a model is created in a different database, the CLI creates it as a virtual dataset (usingselect * from db_name.schema.table
).SQLAlchemy's
create_engine()
method might require the DB-specific driver to work. This PR adds proper instructions to users when facing this issue. It currently only coverssnowflake
, but covering more engines should be straightforward.