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

fix: remove leading whitespaces on post-hook operations #705

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions dbt/adapters/athena/query_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def add(self, sql: str) -> str:

# alter or vacuum statements don't seem to support properly query comments
# let's just exclude them
sql = sql.lstrip()
if any(sql.lower().startswith(keyword) for keyword in ["alter", "drop", "optimize", "vacuum", "msck"]):
return sql

Expand Down
12 changes: 12 additions & 0 deletions tests/unit/test_query_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,15 @@ def test_no_query_comment_on_msck(self):
self.query_header.comment.append = True
sql = "MSCK REPAIR TABLE"
assert self.query_header.add(sql) == sql

def test_no_query_comment_on_vacuum_with_leading_whitespaces(self):
sanromeo marked this conversation as resolved.
Show resolved Hide resolved
self.query_header.comment.query_comment = "executed by dbt"
self.query_header.comment.append = True
sql = " VACUUM table"
assert self.query_header.add(sql) == "VACUUM table"

def test_no_query_comment_on_vacuum_with_lowercase(self):
self.query_header.comment.query_comment = "executed by dbt"
self.query_header.comment.append = True
sql = "vacuum table"
assert self.query_header.add(sql) == sql
Loading