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

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

Log workAgile BoardRank to TopRank to BottomAdd voteVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.0.0
    • Fix Version/s: None
    • Component/s: CBO, Hive
    • Labels:
      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

          $i18n.getText('security.level.explanation', $currentSelection) Viewable by All Users
          Cancel

            People

            • Assignee:
              Unassigned Assign to me
              Reporter:
              Rajkumar Singh Rajkumar Singh

              Dates

              • Created:
                Updated:

                Issue deployment