fix(prqlc, append): avoid type mismatch with postgres#5343
fix(prqlc, append): avoid type mismatch with postgres#5343
Conversation
|
ok, very reasonable goal! thanks for the PR. quick question: why do we need to skip some tests? I worry a bit that we're splitting the test suite. if we're making per-schema changes, that should allow more queries to work with multiple dialects, iiuc? |
|
The duplicated/skipped tests seem to be a result of the way the current integration test set runs the queries and compares the output to the snapshots. It uses the "generic" dialect for all queries, so it's not possible to test compile output on a per-dialect basis. That said, I think this implementation of Thanks for solving this bug! |
|
ah ha, yes I remember now yeah — we could refactor it into producing:
...that would give us the ability to have some dialects be slightly different without having every single integration test have every single test output but I think this is probably as close as we can get without that change? we can merge if so... |
|
Thanks for the feedback! @kgutwin is correct. In the end, there's no skipped test in this PR. AFAIK, some split is required here because
I agree a refactor of the test suite is warranted and it's worth talking about what we want exactly. For instance:
I feel like that's not something too painful to change in the near future, since |
|
I was feeling a bit inspired by @max-sixty and thought that I could bash that idea out... take a look at #5344 and see if it meets the need! |
|
Thanks @kgutwin! |
|
thanks @Fanaen ! |
Fixes #5341
Postgres sometimes needs help to get column types right with default values in a
append. It needs both left- and right-hand-side queries to be inserted as is. As soon as the default value is in a CTE or aSELECT * FROM (subquery) as table_1, it fails.To fix this, there are two changes:
Postgres, output(our query)instead ofSELECT * FROM (our query) as table_1. This affects both left- and right-hand-side subqueries.UNION,EXCEPTandINTERSECT, opt out of CTEs and use subqueries instead.To avoid issues, the long form still is the default. Only
postgresandduckdbuse the short form.duckdbdoesn't seem to require it, but it simplifies the tests because it's a non-external db.We could easily switch some other dialect to this new form, like MySQL and MSSQL. The only one I know for sure won't work is SQLite, which does not support the short form.
This also required doing some changes on testing. Hope it's not too heavy handed.
appendtests now have both forms for most queries.default-dialectto get SQL output rolling for the secondary form (here, the short one).append_select_nullsto highlight the type mismatchappend_select_simplewhich is the same for all dialectsOne thing I'm not sure about is the subquery naming scheme. Not sure why some index are skipped.