LantaoJin opened a new pull request #28935:
URL: https://github.com/apache/spark/pull/28935


   ### What changes were proposed in this pull request?
   
   This is to address the close one #17953, as a refactor for #28833 
   Adding `HiveNullType`, like `HiveStringType`, to prevent from exception when 
describe tables/views which the schema contain Hive Null (VOID) type.
   
   ### Why are the changes needed?
   
   Spark is incompatible with hive void type. When Hive table schema contains 
void type, DESC table will throw an exception in Spark.
   
   >hive> create table bad as select 1 x, null z from dual;
   >hive> describe bad;
   OK
   x    int     
   z    void
   
   In Spark2.0.x, the behaviour to read this view is normal:
   >spark-sql> describe bad;
   x       int     NULL
   z       void    NULL
   Time taken: 4.431 seconds, Fetched 2 row(s)
   
   But in lastest Spark version, it failed with SparkException: Cannot 
recognize hive type string: void
   
   >spark-sql> describe bad;
   17/05/09 03:12:08 ERROR thriftserver.SparkSQLDriver: Failed in [describe bad]
   org.apache.spark.SparkException: Cannot recognize hive type string: void
   Caused by: org.apache.spark.sql.catalyst.parser.ParseException:
   DataType void() is not supported.(line 1, pos 0)
   == SQL ==  
   void       
   ^^^
           ... 61 more
   org.apache.spark.SparkException: Cannot recognize hive type string: void
   
   ### Does this PR introduce any user-facing change?
   
   No
   
   ### How was this patch tested?
   
   Add unit tests
   
   Also can manual tests
   >spark-sql> describe bad;
   x int NULL
   z null NULL
   Time taken: 0.486 seconds, Fetched 2 row(s)
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to