Skip to content

Commit

Permalink
hotfix: execution in named cells was breaking (#172)
Browse files Browse the repository at this point in the history
* fix: replace % with %% to handle python logic

* fix: hanging macro names led to failed execution

* chore: advance python version

* chore: advance rust version
  • Loading branch information
rsyi authored Jun 11, 2021
1 parent 9d9d3c6 commit d3eaf7b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "whale"
version = "2.1.0-b0"
version = "2.1.0-b1"
authors = ["Robert Yi <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion pipelines/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="whale-pipelines",
version="2.l.0b0",
version="2.l.0b1",
author="Robert Yi",
author_email="[email protected]",
description="A pared-down metadata scraper + SQL runner.",
Expand Down
1 change: 1 addition & 0 deletions pipelines/whale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def run(sql, warehouse_name=None, extra_macros: str = "") -> pd.DataFrame:
sql, connection_name=connection.name, extra_macros=extra_macros
)
LOGGER.info(f"Templated query:\n{sql}")
sql = sql.replace("%", "%%")

result = engine.execute(sql, has_header=True)
headers = next(result)
Expand Down
8 changes: 6 additions & 2 deletions pipelines/whale/utils/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,13 @@ def construct_jinja_statement(clause):
sections = []
for clause in splits:
if state == IN_BLOCK:
processed_clause = function_to_apply_to_block(
clause, **function_kwargs, extra_macros=extra_macros
split_clause = clause.split("\n")
prefix = split_clause[0]
sql = "\n".join(split_clause[1:])
processed_sql = function_to_apply_to_block(
sql, **function_kwargs, extra_macros=extra_macros
)
processed_clause = "\n".join([prefix, processed_sql])
state = OUT_OF_BLOCK
else:
processed_clause = clause
Expand Down

0 comments on commit d3eaf7b

Please sign in to comment.