Bug Report: vtexplain
fails on sharded UNION
queries containing weight_string
#16128
Labels
vtexplain
fails on sharded UNION
queries containing weight_string
#16128
Overview of the Issue
When
vtexplain
is used to generate the query plan for aUNION
query against a sharded keyspace,vtexplain
can fail with errors like:This is caused by the fact that the query planner might inject
WEIGHT_STRING
calls into the per-shard queries. Unfortunatelyvtexplain
treats all function calls as returning integer values (even ifWEIGHT_STRING
actually returns a string).Later,
UNION
queries are handled via theDistinct
primitive that builds a probe table. The probe table uses theNullsafeHashcode
function to generate hash codes for each column, falling back toWEIGHT_STRING
values if a column has an unsupported collation. WhenNullsafeHashcode
is called for theWEIGHT_STRING
column, the original column type is passed in, which causes thecoercion should not try to coerce this value to a text
as theWEIGHT_STRING
function is assumed to return an integer, but the original columns type (VARCHAR
in this case) is passed into theNullsafeHashcode
function.Reproduction Steps
Use the SQL schema from
go/vt/vtexplain/testdata/test-schema.sql
, and the VSchema fromgo/vt/vtexplain/testdata/test-vschema.json
to explain a query like:Binary Version
Operating System and Environment details
Log Fragments
The text was updated successfully, but these errors were encountered: