Skip to content

Commit 62ee42d

Browse files
Merge pull request #110 from github/backport-16129-16159-to-release-16.0-github
Backport vitessio#16129 and vitessio#16159 to v16
2 parents 703fa1c + f6087bf commit 62ee42d

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

go/vt/vtexplain/testdata/multi-output/selectsharded-output.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,9 @@ SELECT id FROM orders WHERE id IN (1, "1", 1)
207207
2 ks_sharded/40-80: select id from orders where id in (1, '1', 1) limit 10001
208208

209209
----------------------------------------------------------------------
210+
(SELECT user.id, user.name FROM user WHERE user.id = 1) UNION (SELECT user.id, user.name FROM user WHERE user.id = 3)
211+
212+
1 ks_sharded/-40: select distinct `user`.id, `user`.`name`, weight_string(`user`.id), weight_string(`user`.`name`) from `user` where `user`.id = 1 limit 10001
213+
1 ks_sharded/40-80: select distinct `user`.id, `user`.`name`, weight_string(`user`.id), weight_string(`user`.`name`) from `user` where `user`.id = 3 limit 10001
214+
215+
----------------------------------------------------------------------

go/vt/vtexplain/testdata/selectsharded-queries.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ select id from user where not id in (select col from music where music.user_id =
3838

3939
SELECT user.id, user.name, name_info.info FROM user INNER JOIN music ON (user.id = music.user_id) LEFT OUTER JOIN name_info ON (user.name = name_info.name);
4040

41-
SELECT id FROM orders WHERE id IN (1, "1", 1)
41+
SELECT id FROM orders WHERE id IN (1, "1", 1);
42+
43+
(SELECT user.id, user.name FROM user WHERE user.id = 1) UNION (SELECT user.id, user.name FROM user WHERE user.id = 3);

go/vt/vtexplain/vtexplain_vttablet.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,15 @@ func inferColTypeFromExpr(node sqlparser.Expr, tableColumnMap map[sqlparser.Iden
803803
colTypes = append(colTypes, colType)
804804
}
805805
case sqlparser.Callable:
806-
// As a shortcut, functions are integral types
807-
colNames = append(colNames, sqlparser.String(node))
808-
colTypes = append(colTypes, querypb.Type_INT32)
806+
switch node := node.(type) {
807+
case *sqlparser.WeightStringFuncExpr:
808+
colNames = append(colNames, sqlparser.String(node))
809+
colTypes = append(colTypes, querypb.Type_BINARY)
810+
default:
811+
// As a shortcut, functions are integral types
812+
colNames = append(colNames, sqlparser.String(node))
813+
colTypes = append(colTypes, querypb.Type_INT32)
814+
}
809815
case *sqlparser.Literal:
810816
colNames = append(colNames, sqlparser.String(node))
811817
switch node.Type {

0 commit comments

Comments
 (0)