[ https://issues.apache.org/jira/browse/SPARK-12102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yin Huai updated SPARK-12102: ----------------------------- Assignee: Dilip Biswal > Cast a non-nullable struct field to a nullable field during analysis > -------------------------------------------------------------------- > > Key: SPARK-12102 > URL: https://issues.apache.org/jira/browse/SPARK-12102 > Project: Spark > Issue Type: Bug > Components: SQL > Reporter: Yin Huai > Assignee: Dilip Biswal > Fix For: 2.0.0 > > > If you try {{sqlContext.sql("select case when 1>0 then struct(1, 2, 3, > cast(hash(4) as int)) else struct(1, 2, 3, 4) end").printSchema}}, you will > see {{org.apache.spark.sql.AnalysisException: cannot resolve 'CASE WHEN (1 > > 0) THEN > struct(1,2,3,cast(HiveGenericUDF#org.apache.hadoop.hive.ql.udf.generic.GenericUDFHash(4) > as int)) ELSE struct(1,2,3,4)' due to data type mismatch: THEN and ELSE > expressions should all be same type or coercible to a common type; line 1 pos > 85}}. > The problem is the nullability difference between {{4}} (non-nullable) and > {{hash(4)}} (nullable). > Seems it makes sense to cast the nullability in the analysis. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org