confluentinc / ksql

The database purpose-built for stream processing applications.
https://ksqldb.io
Other
124 stars 1.04k forks source link

i can't get columns which are not in group by #9729

Open john1337 opened 1 year ago

john1337 commented 1 year ago

when i am using ksql,i met the following errors: Could not determine output schema for query due to error: Non-aggregate SELECT expression(s) not part of GROUP BY:PRODUCTID Either add the column(s) to the GROUP BY or remove them from the SELECT.

create table ts3 as select productid,deviceid,count(*) from ts1 group by deviceid emit changes;

can i do get columns which are not included in group by

suhas-satish commented 1 year ago

This is working as designed.

john1337 commented 1 year ago

This is working as designed.

so when will this feature be released,has any plan date?

TheDarkFlame commented 1 year ago

when i am using ksql,i met the following errors: Could not determine output schema for query due to error: Non-aggregate SELECT expression(s) not part of GROUP BY:PRODUCTID Either add the column(s) to the GROUP BY or remove them from the SELECT.

create table ts3 as select productid,deviceid,count(*) from ts1 group by deviceid emit changes;

can i do get columns which are not included in group by

Perhaps I could expand on @suhas-satish 's statement.

If you are trying to select columns that are not in the group by, or are being aggregated

Then how would ksqldb determine which value to use? by definition you are grouping multiple rows (in no particular order), you cannot select a single field, your fields must either be common among all the rows (ie, part of the group by) or an aggregate (ie, part of the aggregate functions)