Created on 09-28-2016 03:11 AM - edited 09-16-2022 03:42 AM
impala> create table test_escape_group_by (s string); impala> insert into table test_escape_group_by values("longstring"), ("short"); impala> select my_escape_string(s) as es from test_escape_group_by; longstring short impala> select my_escape_string(s) as es from test_escape_group_by group by es; shorttring shortWe can see that the beginning part of 'longstring' is replaced by 'short'. Here is the definition of my_escape_string:
public class MyEscapeString extends UDF { public Text evaluate(Text para) throws ParseException { if ((null == para) || ("".equals(para.toString()))) { return new Text(""); } return new Text(para.toString().replace("\\", "\\\\").replace("\"", "\\\"")); } }My Question: Is this a bug of impala, or how can I rewritten the Java UDF to avoid such errors.
Created 10-10-2016 09:55 AM
Hey,
This looks like a bug and can be reproduced even on the latest versions of Impala. Thanks for sharing the repro steps with us. I created a jira https://issues.cloudera.org/browse/IMPALA-4266 with a simpler UDF so its easy to follow. Your UDF implementation looks fine and is likely not causing this issue.
- Bharath
Created 10-10-2016 09:55 AM
Hey,
This looks like a bug and can be reproduced even on the latest versions of Impala. Thanks for sharing the repro steps with us. I created a jira https://issues.cloudera.org/browse/IMPALA-4266 with a simpler UDF so its easy to follow. Your UDF implementation looks fine and is likely not causing this issue.
- Bharath