diff --git a/go/vt/vtexplain/testdata/multi-output/selectsharded-output.txt b/go/vt/vtexplain/testdata/multi-output/selectsharded-output.txt index fa6637e58ce..2b74d49911c 100644 --- a/go/vt/vtexplain/testdata/multi-output/selectsharded-output.txt +++ b/go/vt/vtexplain/testdata/multi-output/selectsharded-output.txt @@ -72,12 +72,12 @@ select name, count(*) from user group by name /* scatter aggregate */ 1 ks_sharded/c0-: select name, count(*) from user group by name limit 10001 /* scatter aggregate */ ---------------------------------------------------------------------- -select 1, "hello", 3.14 from user limit 10 /* select constant sql values */ +select 1, "hello", 3.14, null from user limit 10 /* select constant sql values */ -1 ks_sharded/-40: select 1, 'hello', 3.14 from user limit 10 /* select constant sql values */ -1 ks_sharded/40-80: select 1, 'hello', 3.14 from user limit 10 /* select constant sql values */ -1 ks_sharded/80-c0: select 1, 'hello', 3.14 from user limit 10 /* select constant sql values */ -1 ks_sharded/c0-: select 1, 'hello', 3.14 from user limit 10 /* select constant sql values */ +1 ks_sharded/-40: select 1, 'hello', 3.14, null from user limit 10 /* select constant sql values */ +1 ks_sharded/40-80: select 1, 'hello', 3.14, null from user limit 10 /* select constant sql values */ +1 ks_sharded/80-c0: select 1, 'hello', 3.14, null from user limit 10 /* select constant sql values */ +1 ks_sharded/c0-: select 1, 'hello', 3.14, null from user limit 10 /* select constant sql values */ ---------------------------------------------------------------------- select * from (select id from user) s /* scatter paren select */ diff --git a/go/vt/vtexplain/testdata/selectsharded-queries.sql b/go/vt/vtexplain/testdata/selectsharded-queries.sql index b9c42e3f05d..e2fdfc3171e 100644 --- a/go/vt/vtexplain/testdata/selectsharded-queries.sql +++ b/go/vt/vtexplain/testdata/selectsharded-queries.sql @@ -11,7 +11,7 @@ select count(*) from user where id = 1 /* point aggregate */; select count(*) from user where name in ('alice','bob') /* scatter aggregate */; select name, count(*) from user group by name /* scatter aggregate */; -select 1, "hello", 3.14 from user limit 10 /* select constant sql values */; +select 1, "hello", 3.14, null from user limit 10 /* select constant sql values */; select * from (select id from user) s /* scatter paren select */; select name from user where id = (select id from t1) /* non-correlated subquery as value */; @@ -31,4 +31,4 @@ select id, case when name = 'alice' then 'ALICE' when name = 'bob' then 'BOB' en select id, case when name = 'alice' then 'ALICE' when name = 'bob' then 'BOB' else 'OTHER' end as name from user where id = 1 /* select case */; select id, case when substr(name, 1, 5) = 'alice' then 'ALICE' when name = 'bob' then 'BOB' else 'OTHER' end as name from user where id = 1 /* select case */; -select id, 'abc' as test from user where id = 1 union all select id, 'def' as test from user where id = 1 union all select id, 'ghi' as test from user where id = 1 /* union all */; \ No newline at end of file +select id, 'abc' as test from user where id = 1 union all select id, 'def' as test from user where id = 1 union all select id, 'ghi' as test from user where id = 1 /* union all */; diff --git a/go/vt/vtexplain/vtexplain_vttablet.go b/go/vt/vtexplain/vtexplain_vttablet.go index de607b11deb..f66603b230a 100644 --- a/go/vt/vtexplain/vtexplain_vttablet.go +++ b/go/vt/vtexplain/vtexplain_vttablet.go @@ -628,6 +628,9 @@ func inferColTypeFromExpr(node sqlparser.Expr, colTypeMap map[string]querypb.Typ colNames, colTypes = inferColTypeFromExpr(node.Expr, colTypeMap, colNames, colTypes) case *sqlparser.CaseExpr: colNames, colTypes = inferColTypeFromExpr(node.Whens[0].Val, colTypeMap, colNames, colTypes) + case *sqlparser.NullVal: + colNames = append(colNames, sqlparser.String(node)) + colTypes = append(colTypes, querypb.Type_NULL_TYPE) default: log.Errorf("vtexplain: unsupported select expression type +%v node %s", reflect.TypeOf(node), sqlparser.String(node)) }