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

Schema name in Postgres from is incorrectly quoted #822

Closed
mklopets opened this issue Jul 18, 2022 · 6 comments
Closed

Schema name in Postgres from is incorrectly quoted #822

mklopets opened this issue Jul 18, 2022 · 6 comments
Labels
bug Invalid compiler output or panic priority

Comments

@mklopets
Copy link
Collaborator

mklopets commented Jul 18, 2022

This behaviour was introduced in #809

Assume you have a Postgres database with a schema some_schema (this could even be public)

prql dialect:postgres
from some_schema.tablename

compiles to

SELECT
  some_schema.tablename.*
FROM
  "some_schema.tablename"

which is an invalid query – the schema name shouldn't be inside quotes (postgres will complain with relation "some_schema.tablename" does not exist.

If we want to keep the quotes, a valid Postgres query would be:

-  "some_schema.tablename"
+  "some_schema"."tablename"

or just

-  "some_schema.tablename"
+  some_schema.tablename
@max-sixty
Copy link
Member

max-sixty commented Jul 18, 2022

Ah, this is unfortunate, #809 was quite elegant. We can make it split by . I think.

Does this block you? We can revert #809 if it does (we have a policy of fast merges and fast reverts!)

@max-sixty max-sixty added the bug Invalid compiler output or panic label Jul 18, 2022
@mklopets
Copy link
Collaborator Author

mklopets commented Jul 18, 2022

it's non-blocking until prql-js has a new version we need to update to for other reasons (the latest published version, v0.2.2 is fine)

splitting by . would be neat, though I'm not sure which other dialects this applies to

@max-sixty
Copy link
Member

OK. Probably we should revert rather than block a release, but let me see whether it's an easy fix

@blackary
Copy link

Similar issue with BigQuery

prql dialect:bigquery
from db.schema.table

->

SELECT
  db.schema.table.*
FROM
  `db.schema.table`

Which causes this error:
Unrecognized name: db at [2:3]

In this case the backticks after the FROM are fine, but they are missing after the SELECT

-  db.schema.table.*
+  `db.schma.table`.*

@huw
Copy link

huw commented Jul 22, 2022

This is also breaking Spark SQL (not a supported dialect, I know)—in this case, the FROM clause needs a table name of either some_schema.tablename or

`some_schema`.`tablename`

(Seems like it would be ideal to split on . in all dialects, regardless of quote marks).

@max-sixty
Copy link
Member

Closed by #838. Thanks for everyone's patience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Invalid compiler output or panic priority
Projects
None yet
Development

No branches or pull requests

4 participants