Skip to content

Commit

Permalink
change test to use the new code
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Jan 25, 2025
1 parent db97fc9 commit 82c939a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions go/vt/vtgate/semantics/typer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ func TestNormalizerAndSemanticAnalysisIntegration(t *testing.T) {

for _, test := range tests {
t.Run(test.query, func(t *testing.T) {
parse, err := sqlparser.NewTestParser().Parse(test.query)
parse, known, err := sqlparser.NewTestParser().Parse2(test.query)
require.NoError(t, err)

err = sqlparser.Normalize(parse, sqlparser.NewReservedVars("bv", sqlparser.BindVars{}), map[string]*querypb.BindVariable{})
rv := sqlparser.NewReservedVars("", known)
out, err := sqlparser.PrepareAST(parse, rv, map[string]*querypb.BindVariable{}, true, "d", 0, "", map[string]string{}, nil, nil)
require.NoError(t, err)

st, err := Analyze(parse, "d", fakeSchemaInfo())
st, err := Analyze(out.AST, "d", fakeSchemaInfo())
require.NoError(t, err)
bv := parse.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr.(*sqlparser.Argument)
bv := out.AST.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr.(*sqlparser.Argument)
typ, found := st.ExprTypes[bv]
require.True(t, found, "bindvar was not typed")
require.Equal(t, test.typ, typ.Type().String())
Expand All @@ -68,15 +69,15 @@ func TestColumnCollations(t *testing.T) {

for _, test := range tests {
t.Run(test.query, func(t *testing.T) {
parse, err := sqlparser.NewTestParser().Parse(test.query)
ast, err := sqlparser.NewTestParser().Parse(test.query)
require.NoError(t, err)

err = sqlparser.Normalize(parse, sqlparser.NewReservedVars("bv", sqlparser.BindVars{}), map[string]*querypb.BindVariable{})
out, err := sqlparser.PrepareAST(ast, sqlparser.NewReservedVars("bv", sqlparser.BindVars{}), map[string]*querypb.BindVariable{}, true, "d", 0, "", map[string]string{}, nil, nil)
require.NoError(t, err)

st, err := Analyze(parse, "d", fakeSchemaInfo())
st, err := Analyze(out.AST, "d", fakeSchemaInfo())
require.NoError(t, err)
col := extract(parse.(*sqlparser.Select), 0)
col := extract(out.AST.(*sqlparser.Select), 0)
typ, found := st.TypeForExpr(col)
require.True(t, found, "column was not typed")

Expand Down

0 comments on commit 82c939a

Please sign in to comment.