-
Notifications
You must be signed in to change notification settings - Fork 9
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
Error: mismatched input WITH - CTE's in views #16
Comments
Thanks, interesting find! It would be good to find out in what cases Athena does support CTEs. Maybe we need to wrap the inner query in a |
Ah, interesting, yes wrapping in the SELECT statement gets around the problem. |
Yeah, that makes sense, that's also how I use dbt generally. We could likely change the adapter to wrap all queries in a select to workaround this issue. |
As I struggled a bit to understand the way with statements work, here is a full example
|
Thanks @AndresNamm !! That worked great! |
Maybe something that should be added to the docs while we don't workaround that Athena doesn't support it in a create table/view as statement? |
I believe we should just change the create_view_as and create_table_as macro's to generate a view starting with Help welcome! |
I tried setting up a project in dbt using the adapter today and ran into a problem using WITH statement in a view.
I get the error:
An error occurred (InvalidRequestException) when calling the StartQueryExecution operation: line 2:5: mismatched input 'WITH' expecting {'(', 'SELECT', 'VALUES', 'TABLE'}
Looking at the logs, this appears to be because dbt is wrapping the entire SELECT statement, including the CTE's generated by WITH statement, in parentheses, as:
create view my_table as ( WITH my_other_table AS ( ... ) SELECT .... )
On closer inspection there actually only appears to be an opening parenthesis and not a closing one in the logs. However, running the statement with one or both parentheses in Athena yields the same error.
Are WITH statements currently supported in views using the adapter?
Thanks!
The text was updated successfully, but these errors were encountered: