jonahgao commented on code in PR #14130:
URL: https://github.com/apache/datafusion/pull/14130#discussion_r1916749598
##########
datafusion/optimizer/tests/optimizer_integration.rs:
##########
@@ -387,6 +389,30 @@ fn
select_correlated_predicate_subquery_with_uppercase_ident() {
assert_eq!(expected, format!("{plan}"));
}
+// The test should return an error
+// because the wildcard didn't be expanded before type coercion
+#[test]
+fn test_union_coercion_with_wildcard() -> Result<()> {
+ let dialect = PostgreSqlDialect {};
+ let context_provider = MyContextProvider::default();
+ let sql = "select * from (SELECT col_int32, col_uint32 FROM test) union
all select * from(SELECT col_uint32, col_int32 FROM test)";
+ let statements = Parser::parse_sql(&dialect, sql)?;
+ let sql_to_rel = SqlToRel::new(&context_provider);
+ let logical_plan =
sql_to_rel.sql_statement_to_plan(statements[0].clone())?;
+
+ if let LogicalPlan::Union(union) = logical_plan {
Review Comment:
We need to ensure that logical_plan is definitely a union. This could happen
if `sql_statement_to_plan` changes in the future, and then this test would
become invalid. We can do it like this:
```rust
let LogicalPlan::Union(union) = logical_plan else {
panic!("Expected Union plan");
};
let err = TypeCoercionRewriter::coerce_union(union)
.err()
.unwrap()
.to_string();
assert_contains!(
err,
"Error during planning: Wildcard should be expanded before type
coercion"
);
```
--
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]