Details
Description
When I run following:
{{CREATE TABLE temp_test AS SELECT CAST(null AS bigint) as nullable_int }}
with the error:
Unsupported type 'null_type' in column 'nullable_int' of table 'temp_test'
The reason for this, I assume, is following. In the INSERT statements data types of result set's columns are retrieved from the resulting values:
https://github.com/apache/impala/blob/789c5aac23480acc6e18c057b767b65fdd791c97/fe/src/main/java/org/apache/impala/analysis/InsertStmt.java#L275
Whereas in CTAS they are calculated via base table of the column (and there is no base table for NULL):
https://github.com/apache/impala/blob/ba84ad03cb83d7f7aed8524fcfbb0e2cdc9fdd53/fe/src/main/java/org/apache/impala/analysis/CreateTableAsSelectStmt.java#L171