Skip to content

Commit

Permalink
UNION column type coercion (#14245)
Browse files Browse the repository at this point in the history
Co-authored-by: Harshit Gangal <[email protected]>
  • Loading branch information
systay and harshit-gangal authored Oct 12, 2023
1 parent 0dca529 commit 4478339
Show file tree
Hide file tree
Showing 32 changed files with 642 additions and 365 deletions.
4 changes: 4 additions & 0 deletions go/test/endtoend/vtgate/queries/union/union_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func TestUnionAll(t *testing.T) {
func TestUnion(t *testing.T) {
mcmp, closer := start(t)
defer closer()
mcmp.Exec("insert into t1(id1, id2) values(1, 1), (2, 2)")

mcmp.AssertMatches(`SELECT 1 UNION SELECT 1 UNION SELECT 1`, `[[INT64(1)]]`)
mcmp.AssertMatches(`SELECT 1,'a' UNION SELECT 1,'a' UNION SELECT 1,'a' ORDER BY 1`, `[[INT64(1) VARCHAR("a")]]`)
Expand All @@ -126,4 +127,7 @@ func TestUnion(t *testing.T) {
mcmp.AssertMatches(`(SELECT 1,'a') UNION ALL (SELECT 1,'a') UNION ALL (SELECT 1,'a') ORDER BY 1`, `[[INT64(1) VARCHAR("a")] [INT64(1) VARCHAR("a")] [INT64(1) VARCHAR("a")]]`)
mcmp.AssertMatches(`(SELECT 1,'a') ORDER BY 1`, `[[INT64(1) VARCHAR("a")]]`)
mcmp.AssertMatches(`(SELECT 1,'a' order by 1) union (SELECT 1,'a' ORDER BY 1)`, `[[INT64(1) VARCHAR("a")]]`)
if utils.BinaryIsAtVersion(19, "vtgate") {
mcmp.AssertMatches(`(SELECT id2,'a' from t1 where id1 = 1) union (SELECT 'a',id2 from t1 where id1 = 2)`, `[[VARCHAR("1") VARCHAR("a")] [VARCHAR("a") VARCHAR("2")]]`)
}
}
Loading

0 comments on commit 4478339

Please sign in to comment.