Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Comments

TAJO-2160: Implement string_agg function.#1029

Closed
combineads wants to merge 1 commit intoapache:masterfrom
combineads:TAJO-2160
Closed

TAJO-2160: Implement string_agg function.#1029
combineads wants to merge 1 commit intoapache:masterfrom
combineads:TAJO-2160

Conversation

@combineads
Copy link
Contributor

@combineads combineads commented May 20, 2016

I'll implement to concatenate the strings of a field within a group by query.
I have a table:
ID COMPANY_ID EMPLOYEE
1 1 Anna
2 1 Bill
3 2 Carol
4 2 Dave

and I wanted to group by company_id to get something like:

SELECT company_id, string_agg(employee, ', ')
FROM mytable
GROUP BY company_id;

COMPANY_ID EMPLOYEE
1 Anna, Bill
2 Carol, Dave

PostgreSQL supports string_agg function.

http://www.postgresql.org/docs/current/static/functions-aggregate.html#FUNCTIONS-AGGREGATE-TABLE

Thank you.

}

message StringAggProto {
required string value = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this proto is unnecessary define. the StringAgg is only to aggregate a value.
What do you think about that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. I’m wrong. delimiter should send to context for merge phase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to keep the second parameter, delimiter, in the merge method of StringAgg when the second stages execute to merge the result of fisrt stage of StringAgg.

@jihoonson
Copy link
Contributor

This patch looks good to me. @jinossy do you have more comments?

@jinossy
Copy link
Member

jinossy commented Jul 6, 2016

@jihoonson
No. +1 The patch looks good to me.
@combineads
Thanks for your contribution!

@asfgit asfgit closed this in 9cf9f75 Jul 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants