Rajkumar Singh created HIVE-25024: ------------------------------------- Summary: Length function on char field yield incorrect result if CBO is enable Key: HIVE-25024 URL: https://issues.apache.org/jira/browse/HIVE-25024 Project: Hive Issue Type: Bug Components: CBO, Hive Affects Versions: 4.0.0 Reporter: Rajkumar Singh
Steps to repro: {code:java} create table char_test(val char(10)); insert into table char_test values ('abc') select * from char_test; +----------------+ | char_test.val | +----------------+ | abc | +----------------+ select length(val) from char_test where val='abc'; +------+ | _c0 | +------+ | 10 | +------+ {code} The problem surface when CBO is enabled and query have a predicate on the char field. the filter form in this case is 'abc ' (extra padded char) of string type since this is constant comparison. for string type genericudflength will not strip the extra chars. https://github.com/apache/hive/blob/1758c8c857f8a6dc4c9dc9c522de449f53e5e5cc/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java#L943 -- This message was sent by Atlassian Jira (v8.3.4#803005)