Skip to content

validation for GROUP BY is incorrect in PostgreSQL timescaledb #1315

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

Closed
starudream opened this issue Nov 29, 2021 · 2 comments · Fixed by #1348
Closed

validation for GROUP BY is incorrect in PostgreSQL timescaledb #1315

starudream opened this issue Nov 29, 2021 · 2 comments · Fixed by #1348
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@starudream
Copy link

starudream commented Nov 29, 2021

Version

1.11.0

What happened?

in latest version: v1.11.0

ref pr: #1285

Relevant log output

# package gen
query.sql:25:10: column reference "bucket" not found

Database schema

CREATE TABLE IF NOT EXISTS weather_metrics
(
    time             TIMESTAMP WITHOUT TIME ZONE NOT NULL,
    timezone_shift   INT                         NULL,
    city_name        TEXT                        NULL,
    temp_c           DOUBLE PRECISION            NULL,
    feels_like_c     DOUBLE PRECISION            NULL,
    temp_min_c       DOUBLE PRECISION            NULL,
    temp_max_c       DOUBLE PRECISION            NULL,
    pressure_hpa     DOUBLE PRECISION            NULL,
    humidity_percent DOUBLE PRECISION            NULL,
    wind_speed_ms    DOUBLE PRECISION            NULL,
    wind_deg         INT                         NULL,
    rain_1h_mm       DOUBLE PRECISION            NULL,
    rain_3h_mm       DOUBLE PRECISION            NULL,
    snow_1h_mm       DOUBLE PRECISION            NULL,
    snow_3h_mm       DOUBLE PRECISION            NULL,
    clouds_percent   INT                         NULL,
    weather_type_id  INT                         NULL
);

SQL queries

SELECT time_bucket('15 days', time) AS bucket, city_name, AVG(temp_c)
FROM weather_metrics
WHERE time > NOW() - (6 * INTERVAL '1 month')
GROUP BY bucket, city_name
ORDER BY bucket DESC;

Configuration

version: "1"
packages:
  - name: "gen"
    path: "gen"
    queries: "query.sql"
    schema: "query.sql"
    engine: "postgresql"

Playground URL

https://play.sqlc.dev/p/875234d4bd68eeabdb60d76859ea6597ed3c7f26607986a4c77eb86336a2c3aa

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@starudream starudream added bug Something isn't working triage New issues that hasn't been reviewed labels Nov 29, 2021
@jfxio
Copy link

jfxio commented Nov 29, 2021

This is also breaking us.

@starudream
Copy link
Author

@kyleconroy @timstudd

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

Successfully merging a pull request may close this issue.

2 participants