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

Sometimes difficulty using own CTEs in expressions #7

Open
akdor1154 opened this issue Oct 26, 2020 · 1 comment
Open

Sometimes difficulty using own CTEs in expressions #7

akdor1154 opened this issue Oct 26, 2020 · 1 comment

Comments

@akdor1154
Copy link
Owner

Tested with snowflake, seems to work in some cases and fail in others.

q1 = Q(...)
q2 = Q(lambda: f"""
with cte as (
  select blah from foo join {q1}
)
select blah
""")

syntax error line * at position 0 unexpected 'with'

@akdor1154
Copy link
Owner Author

this hack is useful, considering including it:


# TODO add to csql
def withhack(q):
	import re
	pat = re.compile(r'^[\s\n]*with\s', re.DOTALL)
	return pat.sub(', ', q)

print(withhack('\n with hi as '))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant