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

HPL/SQL: Comparison if not null-safe

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Patch Available
    • Major
    • Resolution: Unresolved
    • None
    • None
    • hpl/sql
    • None

    Description

      This bug is part of a series of issues and surprising behavior I encountered writing a reporting script that would aggregate values and give rows different classifications based on an the aggregate. Addressing some or all of these issues would make HPL/SQL more accessible to newcomers.

      If you run a statement like:

        if val1i > val2i then
          print('val1 greater');
        end if;
      

      And either val1 or val2 is null, you will get an exception similar to the following:

      Unhandled exception in HPL/SQL
      java.lang.NullPointerException
              at org.apache.hive.hplsql.Var.compareTo(Var.java:453)
              at org.apache.hive.hplsql.Expression.operatorCompare(Expression.java:454)
              at org.apache.hive.hplsql.Expression.execBoolBinary(Expression.java:178)
              at org.apache.hive.hplsql.Exec.visitBool_expr_binary(Exec.java:1589)
              at org.apache.hive.hplsql.Exec.visitBool_expr_binary(Exec.java:52)
              at org.apache.hive.hplsql.HplsqlParser$Bool_expr_binaryContext.accept(HplsqlParser.java:19397)
              at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:70)
              at org.apache.hive.hplsql.HplsqlBaseVisitor.visitBool_expr_atom(HplsqlBaseVisitor.java:1316)
              at org.apache.hive.hplsql.HplsqlParser$Bool_expr_atomContext.accept(HplsqlParser.java:18985)
              at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:42)
              at org.apache.hive.hplsql.Expression.visit(Expression.java:660)
              at org.apache.hive.hplsql.Expression.eval(Expression.java:624)
              at org.apache.hive.hplsql.Expression.execBool(Expression.java:121)
      

      Attachments

        1. HIVE-17029.1.patch
          2 kB
          Dmitry Tolpeko

        Activity

          People

            dmtolpeko Dmitry Tolpeko
            cartershanklin Carter Shanklin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: