Skip to content
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

add optional role argument, fix messaging around permissions errors #291

Merged
merged 2 commits into from
Feb 20, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
changed_tests := `git status --porcelain | grep '^\(M\| M\|A\| A\)' | awk '{ print $$2 }' | grep '\/test_[a-zA-Z_\-\.]\+.py'`

install:
pip install .
pip install --upgrade .
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it turns out this is needed for re-installation to work.


test:
@echo "Full test run starting..."
Expand Down
8 changes: 8 additions & 0 deletions dbt/adapters/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ def exception_handler(connection, cursor, model_name, query):
except snowflake.connector.errors.ProgrammingError as e:
if 'Empty SQL statement' in e.msg:
logger.debug("got empty sql statement, moving on")
elif 'This session does not have a current database' in e.msg:
handle.rollback()
raise dbt.exceptions.FailedToConnectException(
('{}\n\nThis error sometimes occurs when invalid credentials '
'are provided, or when your default role does not have '
'access to use the specified database. Please double check '
'your profile and try again.').format(str(e)))
else:
handle.rollback()
raise dbt.exceptions.ProgrammingException(str(e))
Expand Down Expand Up @@ -96,6 +103,7 @@ def open_connection(cls, connection):
database=credentials.get('database'),
schema=credentials.get('schema'),
warehouse=credentials.get('warehouse'),
role=credentials.get('role', None),
autocommit=False
)

Expand Down
3 changes: 2 additions & 1 deletion dbt/contracts/connection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from voluptuous import Schema, Required, All, Any, Extra, Range
from voluptuous import Schema, Required, All, Any, Extra, Range, Optional
from voluptuous.error import MultipleInvalid

from dbt.exceptions import ValidationException
Expand Down Expand Up @@ -28,6 +28,7 @@
Required('database'): str,
Required('schema'): str,
Required('warehouse'): str,
Optional('role'): str,
})

credentials_mapping = {
Expand Down
3 changes: 2 additions & 1 deletion dbt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def run_from_args(parsed):
dbt.tracking.track_invocation_end(
project=proj, args=parsed, result_type="ok", result=None
)
except dbt.exceptions.NotImplementedException as e:
except (dbt.exceptions.NotImplementedException,
dbt.exceptions.FailedToConnectException) as e:
logger.info('ERROR: {}'.format(e))
dbt.tracking.track_invocation_end(
project=proj, args=parsed, result_type="error", result=str(e)
Expand Down