Skip to content

Commit

Permalink
remove else
Browse files Browse the repository at this point in the history
Signed-off-by: wangweicugw <wangweicugw@163.com>
  • Loading branch information
wangweicugw committed Jan 31, 2024
1 parent f35b917 commit f1b01ea
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
4 changes: 0 additions & 4 deletions go/test/endtoend/vtgate/queries/union/union_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ func TestUnionDistinct(t *testing.T) {
mcmp.AssertMatchesNoOrder(`SELECT 5 from t1 UNION SELECT id2 from t1`, `[[INT64(5)] [INT64(1)] [INT64(2)] [INT64(3)] [INT64(4)]]`)
mcmp.AssertMatchesNoOrder(`SELECT id1 from t1 UNION SELECT 2 from t1`, `[[INT64(1)] [INT64(2)] [INT64(3)] [INT64(4)]]`)
mcmp.AssertMatchesNoOrder(`SELECT id1 from t1 UNION SELECT 5 from t1`, `[[INT64(1)] [INT64(2)] [INT64(3)] [INT64(4)] [INT64(5)]]`)
mcmp.AssertMatchesNoOrder(`select 3 from t1 union select DAY("2024-01-31") from t1`, `[[INT64(3)] [INT64(31)]]`)
mcmp.AssertMatchesNoOrder(`select DAY("2024-01-31") from t1 union select 3 from t1`, `[[INT64(31)] [INT64(3)]]`)
mcmp.AssertMatchesNoOrder(`select DAY("2024-01-31") from t1 union select id1 from t1`, `[[INT64(31)] [INT64(1)] [INT64(2)] [INT64(3)] [INT64(4)]]`)
mcmp.Exec(`select 3 from t1 union select curdate() from t1`)
mcmp.Exec(`select curdate() from t1 union select 3 from t1`)
mcmp.Exec(`select curdate() from t1 union select id1 from t1`)
}
Expand Down
3 changes: 0 additions & 3 deletions go/vt/vtgate/planbuilder/operators/union_merging.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,6 @@ func createMergedUnion(
types := []sqltypes.Type{rt.Type(), lt.Type()}
t := evalengine.AggregateTypes(types)
ctx.SemTable.ExprTypes[col] = evalengine.NewType(t, collations.Unknown)
} else {
ctx.SemTable.CopySemanticInfo(rae.Expr, col)
ctx.SemTable.CopySemanticInfo(lae.Expr, col)
}
ctx.SemTable.Recursive[col] = deps
}
Expand Down
44 changes: 25 additions & 19 deletions go/vt/vtgate/planbuilder/testdata/union_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,9 @@
"Instructions": {
"OperatorType": "Distinct",
"Collations": [
"0"
"(0:1)"
],
"ResultColumns": 1,
"Inputs": [
{
"OperatorType": "Route",
Expand All @@ -383,8 +384,8 @@
"Name": "user",
"Sharded": true
},
"FieldQuery": "select id from `user` where 1 != 1 union select id from music where 1 != 1 union select 1 from dual where 1 != 1",
"Query": "select id from `user` union select id from music union select 1 from dual",
"FieldQuery": "select id, weight_string(id) from (select id from `user` where 1 != 1 union select id from music where 1 != 1 union select 1 from dual where 1 != 1) as dt where 1 != 1",
"Query": "select id, weight_string(id) from (select id from `user` union select id from music union select 1 from dual) as dt",
"Table": "`user`, dual, music"
}
]
Expand Down Expand Up @@ -834,8 +835,9 @@
{
"OperatorType": "Distinct",
"Collations": [
"0"
"(0:1)"
],
"ResultColumns": 1,
"Inputs": [
{
"OperatorType": "Route",
Expand All @@ -844,8 +846,8 @@
"Name": "user",
"Sharded": true
},
"FieldQuery": "select id from `user` where 1 != 1 union select 3 from dual where 1 != 1",
"Query": "select id from `user` union select 3 from dual limit :__upper_limit",
"FieldQuery": "select id, weight_string(id) from (select id from `user` where 1 != 1 union select 3 from dual where 1 != 1) as dt where 1 != 1",
"Query": "select id, weight_string(id) from (select id from `user` union select 3 from dual limit :__upper_limit) as dt",
"Table": "`user`, dual"
}
]
Expand Down Expand Up @@ -1042,7 +1044,7 @@
{
"OperatorType": "Distinct",
"Collations": [
"0",
"(0:1)",
"1"
],
"Inputs": [
Expand Down Expand Up @@ -1572,8 +1574,9 @@
"Instructions": {
"OperatorType": "Distinct",
"Collations": [
"0"
"(0:1)"
],
"ResultColumns": 1,
"Inputs": [
{
"OperatorType": "Route",
Expand All @@ -1582,8 +1585,8 @@
"Name": "user",
"Sharded": true
},
"FieldQuery": "select col1 from `user` where 1 != 1 union select 3 from `user` where 1 != 1",
"Query": "select col1 from `user` union select 3 from `user`",
"FieldQuery": "select col1, weight_string(col1) from (select col1 from `user` where 1 != 1 union select 3 from `user` where 1 != 1) as dt where 1 != 1",
"Query": "select col1, weight_string(col1) from (select col1 from `user` union select 3 from `user`) as dt",
"Table": "`user`"
}
]
Expand All @@ -1602,8 +1605,9 @@
"Instructions": {
"OperatorType": "Distinct",
"Collations": [
"0"
"(0:1)"
],
"ResultColumns": 1,
"Inputs": [
{
"OperatorType": "Route",
Expand All @@ -1612,8 +1616,8 @@
"Name": "user",
"Sharded": true
},
"FieldQuery": "select 3 from `user` where 1 != 1 union select col1 from `user` where 1 != 1",
"Query": "select 3 from `user` union select col1 from `user`",
"FieldQuery": "select `3`, weight_string(`3`) from (select 3 from `user` where 1 != 1 union select col1 from `user` where 1 != 1) as dt where 1 != 1",
"Query": "select `3`, weight_string(`3`) from (select 3 from `user` union select col1 from `user`) as dt",
"Table": "`user`"
}
]
Expand All @@ -1632,8 +1636,9 @@
"Instructions": {
"OperatorType": "Distinct",
"Collations": [
"0"
"(0:1)"
],
"ResultColumns": 1,
"Inputs": [
{
"OperatorType": "Route",
Expand All @@ -1642,8 +1647,8 @@
"Name": "user",
"Sharded": true
},
"FieldQuery": "select 3 from `user` where 1 != 1 union select now() from `user` where 1 != 1",
"Query": "select 3 from `user` union select now() from `user`",
"FieldQuery": "select `3`, weight_string(`3`) from (select 3 from `user` where 1 != 1 union select now() from `user` where 1 != 1) as dt where 1 != 1",
"Query": "select `3`, weight_string(`3`) from (select 3 from `user` union select now() from `user`) as dt",
"Table": "`user`"
}
]
Expand All @@ -1662,8 +1667,9 @@
"Instructions": {
"OperatorType": "Distinct",
"Collations": [
"0"
"(0:1)"
],
"ResultColumns": 1,
"Inputs": [
{
"OperatorType": "Route",
Expand All @@ -1672,8 +1678,8 @@
"Name": "user",
"Sharded": true
},
"FieldQuery": "select now() from `user` where 1 != 1 union select 3 from `user` where 1 != 1",
"Query": "select now() from `user` union select 3 from `user`",
"FieldQuery": "select `now()`, weight_string(`now()`) from (select now() from `user` where 1 != 1 union select 3 from `user` where 1 != 1) as dt where 1 != 1",
"Query": "select `now()`, weight_string(`now()`) from (select now() from `user` union select 3 from `user`) as dt",
"Table": "`user`"
}
]
Expand Down

0 comments on commit f1b01ea

Please sign in to comment.