diff --git a/pkg/sql/logictest/testdata/logic_test/array b/pkg/sql/logictest/testdata/logic_test/array index 6f4e14f22c86..d6d0a826533a 100644 --- a/pkg/sql/logictest/testdata/logic_test/array +++ b/pkg/sql/logictest/testdata/logic_test/array @@ -240,6 +240,10 @@ SELECT ARRAY['a', 'b', 'c'][0] ---- NULL +# Regression test for #52134: make sure this is not an internal error. +query error cannot subscript type string because it is not an array +SELECT '{a,b,c}'[0] + query T SELECT (ARRAY['a', 'b', 'c'])[2] ---- diff --git a/pkg/sql/sem/tree/constant.go b/pkg/sql/sem/tree/constant.go index 6e2c3916a3fd..48105bef4540 100644 --- a/pkg/sql/sem/tree/constant.go +++ b/pkg/sql/sem/tree/constant.go @@ -67,7 +67,7 @@ func typeCheckConstant( ctx context.Context, semaCtx *SemaContext, c Constant, desired *types.T, ) (ret TypedExpr, err error) { avail := c.AvailableTypes() - if desired.Family() != types.AnyFamily { + if !desired.IsAmbiguous() { for _, typ := range avail { if desired.Equivalent(typ) { return c.ResolveAsType(ctx, semaCtx, desired)