Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-25024

Length function on char field yield incorrect result if CBO is enable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.0.0
    • None
    • CBO, Hive
    • None

    Description

      Steps to repro:

      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   |
      +------+
      

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            Rajkumar Singh Rajkumar Singh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: