Skip to content
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

GROUP BY not recognizing SELECT Elements? #512

Closed
kdrakon opened this issue Dec 7, 2017 · 5 comments
Closed

GROUP BY not recognizing SELECT Elements? #512

kdrakon opened this issue Dec 7, 2017 · 5 comments
Assignees

Comments

@kdrakon
Copy link

kdrakon commented Dec 7, 2017

Maybe I've been looking at my screen too long, but doesn't my group by contain the necessary elements to perform a grouping?

ksql> create stream rejected_orders with (kafka_topic='output.rejected_orders', value_format='json') as select * from orders where current_status = 'Rejected';

 Message
----------------------------
 Stream created and running
ksql> describe rejected_orders;

 Field          | Type
----------------------------------
 ROWTIME        | BIGINT
 ROWKEY         | VARCHAR(STRING)
 REQUEST_ID     | BIGINT
 ORDER_ID       | VARCHAR(STRING)
 PLATFORM       | VARCHAR(STRING)
 ORDER_TYPE     | VARCHAR(STRING)
ksql> select request_id, current_status from rejected_orders group by request_id;
Group by elements should match the SELECT expressions.
ksql>

This is running on the Docker image of ksql-cli, version 0.2 (080bbe2bfdbf).

@kdrakon kdrakon changed the title "GROUP BY" not recognizing SELECT Elements? GROUP BY not recognizing SELECT Elements? Dec 7, 2017
@kdrakon
Copy link
Author

kdrakon commented Dec 7, 2017

I was actually trying to initially perform the following:

create table rejected_orders_table with (kafka_topic='output.rejected_orders_table', 
value_format='json') as select request_id, current_status from rejected_orders 
group by request_id;

@hjafarpour hjafarpour self-assigned this Dec 7, 2017
@hjafarpour
Copy link
Contributor

@kdrakon currently KSQL only supports GROUP BY clause with aggregate functions so you need to use at least one aggregate function such as count to use GROUP BY.

@kdrakon
Copy link
Author

kdrakon commented Dec 7, 2017

Thanks for clarifying @hjafarpour

@kdrakon kdrakon closed this as completed Dec 7, 2017
@kdrakon
Copy link
Author

kdrakon commented Dec 7, 2017

Would
select request_id, count(request_id), current_status from rejected_orders group by request_id;
be expected to work then, because I'm getting the same error message?

@kdrakon kdrakon reopened this Dec 7, 2017
@kdrakon
Copy link
Author

kdrakon commented Dec 7, 2017

Ah, I see, the above looks to be working if I remove the current_status field.

@kdrakon kdrakon closed this as completed Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants