jonahgao commented on issue #12105:
URL: https://github.com/apache/datafusion/issues/12105#issuecomment-2303790027

   Sorry for introducing this behavior change. There are two reasons we can't 
perform coercion when building unions.
   1. We can't get a correct common schema without performing type coercion for 
expressions, just like the case in #11742.
   2. [Wildcard expansion](https://github.com/apache/datafusion/pull/11681) was 
moved to the analyzer recently. When union  the two following projections, the 
number of their expressions will be different, resulting in an inability to 
perform type coercion.
   ```sql
   create table t1(a int, b int);
   create table t2(c int, d int);
   select * from t1 union select c, d from t2;
   ```
   
   I think it's reasonable to make `coerce_union_schema` public, allowing users 
to coerce unions if they are not affected by the aforementioned scenarios.
   
   Another potential solution might be to manually run the necessary Analyzer 
rules, such as `ExpandWildcardRule` and `TypeCoercion`, after step 1.


-- 
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.

To unsubscribe, e-mail: [email protected]

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