-
Notifications
You must be signed in to change notification settings - Fork 731
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
Materialized View does not enforce columns names - 1.13.0 #1545
Comments
The following also compiles, even though SELECT SUM(earned) as total_earned,
pid
FROM ten_day_earnings
GROUP BY pid
ORDER BY total_ear DESC
LIMIT 10; |
It also seems like it doesn't enforce not null checks on aliased columns. The first MV below has CREATE MATERIALIZED VIEW IF NOT EXISTS ten_day_earnings
WITH (timescaledb.continuous) AS
SELECT time_bucket(INTERVAL '10 day', ts) AS bucket,
(data->>'winning_player_id')::TEXT AS pid,
SUM((data->>'tokens_gained')::INT8) AS earned
FROM kpis
WHERE event_id = 'player.defeated'
AND (data::JSON->>'player_id') = player_id
GROUP BY pid, bucket
;
CREATE MATERIALIZED VIEW IF NOT EXISTS ten_day_losings
WITH (timescaledb.continuous) AS
SELECT time_bucket(INTERVAL '10 day', ts) AS bucket,
player_id AS pid,
SUM((data->>'lobby_price')::INT8) AS lost
FROM kpis
WHERE event_id = 'player.defeated'
AND (data::JSON->>'player_id') = player_id
GROUP BY pid, bucket
; |
@kyleconroy just wanted to bump this as running into this is pretty painful, since I otherwise assume sqlc guarantees correctness :) |
* fix(compiler): Pull in array information from analyzer Fixes #1532 * test(analyzer): Add testcase for #1574 * test: Added test for #1634 * test: Add test case for #1646 * test: Add test for #1714 * Fixes #1912 * test: Add case for #1916 * test: Add two test cases #1917 #1545 * test: Add case for #1979 * test: Add case for #1990
This is fixed in v1.23.0 by enabling the database-backed query analyzer. We added a test case for this issue so it won’t break in the future. You can play around with the working example on the playground |
Version
Other
What happened?
When compiling, sqlc does not verify that the columns exist in the mat view.
See the schema below and the query, the query compiles fine, but running that on the DB throws
column "earned" does not exist
Relevant log output
No response
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/5fa2f34d645dba3e876ff1d17c42a8927cfcb1b3885755abba3604831d8e1010
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: