Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-17818

Cannot SELECT NULL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.0.0, 2.0.1
    • 2.0.2
    • SQL
    • None

    Description

      When connecting to Spark SQL via JDBC/thriftserver, running `SELECT NULL` returns this error:

      0: jdbc:hive2://localhost:10016/> select NULL;
      Error: java.lang.IllegalArgumentException: Unrecognized type name: null (state=,code=0)
      

      Note: I originally pasted in this code erroneously:

      0: jdbc:hive2://localhost:10016/> select cast(NULL as NULL);
      Error: org.apache.spark.sql.catalyst.parser.ParseException: 
      DataType null() is not supported.(line 1, pos 20)
      

      This is a regression from Spark 1.x/Hive QL compatibility. In Spark 1.5.2, The same query returns NULL:

      0: jdbc:hive2://localhost:10015/> select null;
      +-------+--+
      |  _c0  |
      +-------+--+
      | NULL  |
      +-------+--+
      1 row selected (0.658 seconds)
      

      I can select expressions that evaluate to NULL or CAST NULL to different types:

      0: jdbc:hive2://localhost:10016/> select null=null
      0: jdbc:hive2://localhost:10016/> ;
      +----------------+--+
      | (NULL = NULL)  |
      +----------------+--+
      | NULL           |
      +----------------+--+
      1 row selected (0.69 seconds)
      0: jdbc:hive2://localhost:10016/> select cast (NULL as int);
      +--------------------+--+
      | CAST(NULL AS INT)  |
      +--------------------+--+
      | NULL               |
      +--------------------+--+
      1 row selected (0.676 seconds)
      0: jdbc:hive2://localhost:10016/> select cast (NULL as string);
      +-----------------------+--+
      | CAST(NULL AS STRING)  |
      +-----------------------+--+
      | NULL                  |
      +-----------------------+--+
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tnemet Todd Nemet
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: