From 1d76346091e313569cdb5ff6276bcb9e90df9f9b Mon Sep 17 00:00:00 2001 From: Rohan Yadav Date: Wed, 26 Aug 2020 10:49:34 -0400 Subject: [PATCH] opt: add hint to column type mismatch on mutation error Fixes #52298. Release justification: low risk, high benefit change to existing functionality Release note: None --- pkg/sql/opt/optbuilder/mutation_builder.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/sql/opt/optbuilder/mutation_builder.go b/pkg/sql/opt/optbuilder/mutation_builder.go index aba2061ecdea..9348090428a0 100644 --- a/pkg/sql/opt/optbuilder/mutation_builder.go +++ b/pkg/sql/opt/optbuilder/mutation_builder.go @@ -1093,9 +1093,11 @@ func checkDatumTypeFitsColumnType(col *cat.Column, typ *types.T) { } colName := string(col.ColName()) - panic(pgerror.Newf(pgcode.DatatypeMismatch, + err := pgerror.Newf(pgcode.DatatypeMismatch, "value type %s doesn't match type %s of column %q", - typ, col.DatumType(), tree.ErrNameString(colName))) + typ, col.DatumType(), tree.ErrNameString(colName)) + err = errors.WithHint(err, "you will need to rewrite or cast the expression") + panic(err) } // partialIndexCount returns the number of public, write-only, and delete-only