forked from apache/datafusion
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite coerce_plan_expr_for_schema to fix union type coercion (apach…
…e#4862) * Rewrite coerce_plan_expr_for_schema * add integration tests * Update datafusion/expr/src/expr_rewriter.rs Co-authored-by: Andrew Lamb <[email protected]> * fix comment * fix tests * fix tests Co-authored-by: Andrew Lamb <[email protected]>
- Loading branch information
Showing
5 changed files
with
225 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
########## | ||
## UNION Tests | ||
########## | ||
|
||
statement ok | ||
CREATE TABLE t1( | ||
id INT, | ||
name TEXT, | ||
) as VALUES | ||
(1, 'Alex'), | ||
(2, 'Bob'), | ||
(3, 'Alice') | ||
; | ||
|
||
statement ok | ||
CREATE TABLE t2( | ||
id TINYINT, | ||
name TEXT, | ||
) as VALUES | ||
(1, 'Alex'), | ||
(2, 'Bob'), | ||
(3, 'John') | ||
; | ||
|
||
# union with EXCEPT(JOIN) | ||
query T | ||
( | ||
SELECT name FROM t1 | ||
EXCEPT | ||
SELECT name FROM t2 | ||
) | ||
UNION ALL | ||
( | ||
SELECT name FROM t2 | ||
EXCEPT | ||
SELECT name FROM t1 | ||
) | ||
ORDER BY name | ||
---- | ||
Alice | ||
John | ||
|
||
|
||
|
||
# union with type coercion | ||
query T | ||
( | ||
SELECT * FROM t1 | ||
EXCEPT | ||
SELECT * FROM t2 | ||
) | ||
UNION ALL | ||
( | ||
SELECT * FROM t2 | ||
EXCEPT | ||
SELECT * FROM t1 | ||
) | ||
ORDER BY name | ||
---- | ||
3 Alice | ||
3 John |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters