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

MySql5 view parenthesis #94

Open
jdbodyfelt opened this issue May 26, 2022 · 3 comments
Open

MySql5 view parenthesis #94

jdbodyfelt opened this issue May 26, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@jdbodyfelt
Copy link

Describe the bug

A consistent failure on view creation within MySQL5.x, especially those containing UNION, throws

1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union

A traceback to /target/run shows the offending *.sql of form:

create view schema.table__dbt_tmp as (
  (
    select *
    from schema.table_1A
  )
  union
  (
    select *
    from schema.table_1B
  )
);

Removing the first parenthetical grouping, so that the query reads

create view schema.table__dbt_tmp as 
  (
    select *
    from schema.table_1A
  )
  union
  (
    select *
    from schema.table_1B
  )

results in a working query. Likely a final parsing step just needs amending, but not certain yet where that is in the adapter stack...

@jdbodyfelt jdbodyfelt added the bug Something isn't working label May 26, 2022
@fong-kinduct
Copy link

also running into this problem

changing the offending model to {{config(materialized="table")}} rather than {{config(materialized="view")}} works fine as no parenthesis are added.

obviously a table is not as useful as a view, but just figured it was worth adding more data points.

@fong-kinduct
Copy link

funnily enough, ommitting the leading and proceeding parenthesis from your model generates a working view.

select * from table_a ) union ( select * from table_b

@abdel-87
Copy link

abdel-87 commented Oct 9, 2023

Same here. Will this be fixed somewhere soon?
The syntax in Mysql 5.7 should be as simple as. So the wrapping brackets must be removed.

create view [view_name] as
select * from table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants