Skip to content

validation for GROUP BY is incorrect in PostgreSQL timescaledb #1315

Closed
@starudream

Description

@starudream

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNew issues that hasn't been reviewed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions