Skip to content

Error when not using fully qualified field name on select AND group by #8740

@alejandrofm

Description

@alejandrofm

What happens?

I have a view pointing to parquet file(s).
The SELECT statement has the field prd.ad_stats_v.platform, and is grouped by platform (that only exists on that table)
There I get the error:

duckdb.BinderException: Binder Error: column "platform" must appear in the GROUP BY clause or must be part of an aggregate function.
Either add it to the GROUP BY list, or use "ANY_VALUE(platform)" if the exact value of "platform" is not important.
LINE 6:                 prd.ad_stats_v.platform

To Reproduce

conn = duckdb.connect(database='stats.db', read_only=False)
conn.execute("INSTALL httpfs;")
conn.execute("LOAD httpfs;")
#setting credentials here
conn.execute("CREATE SCHEMA IF NOT EXISTS prd;")
conn.execute("CREATE VIEW bds.aux_country_info AS SELECT * FROM read_parquet('s3://data-testing/prd/gamestats/aux_country_info/*');")
conn.execute("CREATE VIEW prd.ad_stats_v AS SELECT * FROM read_parquet('s3://data-testing/prd/gamestats/ad_stats_v/*');")

Query:

select
		event_date,
		app,
		prd.ad_stats_v.country,
		prd.ad_stats_v.platform
	from
		prd.ad_stats_v
	inner join bds.aux_country_info 
                 on
		lower(bds.aux_country_info.country) = lower(prd.ad_stats_v.country)
	where
		true
	group by
		event_date,
		app,
		prd.ad_stats_v.country,
		platform

It works on Redshift/Postgres:
It throws error on duckdb, I have to change the group by
platform to prd.ad_stats_v.platform
to make it work

OS:

MACOS and Linux x64

DuckDB Version:

0.81

DuckDB Client:

python

Full Name:

Alejandro Martínez

Affiliation:

Etermax

Have you tried this on the latest main branch?

I have tested with a release build (and could not test with a main build)

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions