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

I tried the string_concat function. Looks like it only works with comma. #21

Open
d22shen opened this issue Nov 30, 2018 · 3 comments
Open

Comments

@d22shen
Copy link

d22shen commented Nov 30, 2018

I tried to call this function with "-" delimeter, but it looks like comma is still used as part of the separators somehow. I didn't make any change to the udf sample code.

create aggregate function string_concat(string, string) returns string
location '/user/history/libudasample.so'
init_fn='StringConcatInit'
update_fn='StringConcatUpdate'
merge_fn='StringConcatMerge'
finalize_fn='StringConcatFinalize';

My data is as follows:
+----+----------+-----+-----------+--------+
| id | name | age | address | salary |
+----+----------+-----+-----------+--------+
| 7 | Hardik | 22 | MP | 32000 |
| 8 | Komal | 22 | Bhopal | 32000 |
| 9 | Khilan | 25 | Kota | 15000 |
| 12 | Khilan4 | 25 | Kota | 15000 |
| 14 | Khilan6 | 25 | Kota | 15000 |
| 11 | Khilan3 | 25 | Kota | 15000 |
| 15 | Khilan7 | 25 | Kota | 15000 |
| 2 | Khilan | 25 | Delhi | 15000 |
| 13 | Khilan5 | 25 | Kota | 15000 |
| 4 | Chaitali | 25 | Mumbai | 35000 |
| 1 | Ramesh | 32 | Ahmedabad | 20000 |
| 6 | Komal | 22 | MP | 32000 |
| 3 | kaushik | 23 | Kota | 30000 |
| 10 | Khilan2 | 25 | Kota | 15000 |
| 5 | Hardik | 27 | Bhopal | 40000 |
+----+----------+-----+-----------+--------+

select string_concat(name, "-") from employee_kudu group by address;
+----------------------------------------------------------------+
| db_kudu.string_concat(name, '-') |
+----------------------------------------------------------------+
| Chaitali |
| Khilan |
| Khilan5,Khilan,kaushik-Khilan2,Khilan4-Khilan6-Khilan3-Khilan7 |
| Hardik,Komal |
| Ramesh |
| Komal,Hardik |
+----------------------------------------------------------------+

@d22shen
Copy link
Author

d22shen commented Nov 30, 2018

Weird, github won't display understore "_" but it is there in the edit window.
Changed underscore to "-" but the result is actually the same.

@d22shen
Copy link
Author

d22shen commented Nov 30, 2018

To complement this issue, I used the sample on Kudu with two nodes. Is it because of the merge issue? The merge calls "StringConcatUpdate(context, src, ",", dst);" that comma is hard-coded and used.

@timarmstrong
Copy link
Contributor

@d22shen yes it looks like the bug is in StringConcatMerge() like you mentioned. I think to fix it the UDA would need to be modified to store the separator in the intermediate value.

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