Skip to content

Commit

Permalink
refactor: address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Apr 24, 2024
1 parent aae6b16 commit e65487d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion go/vt/vtgate/engine/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package engine

import (
"bytes"
"context"
"fmt"
"strings"
Expand Down Expand Up @@ -107,7 +108,7 @@ func bindvarForType(field *querypb.Field) *querypb.BindVariable {
case querypb.Type_FLOAT32, querypb.Type_FLOAT64:
bv.Value = []byte("0e0")
case querypb.Type_DECIMAL:
bv.Value = []byte(fmt.Sprintf("%s.%s", strings.Repeat("0", max(1, int(field.ColumnLength-field.Decimals))), strings.Repeat("0", max(1, int(field.Decimals)))))
bv.Value = append(append(bytes.Repeat([]byte{'0'}, max(1, int(field.ColumnLength-field.Decimals))), byte('.')), bytes.Repeat([]byte{'0'}, max(1, int(field.Decimals)))...)
default:
return sqltypes.NullBindVariable
}
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/evalengine/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ func TestCompilerSingle(t *testing.T) {
else 0
end) * 0.01`,
result: `DECIMAL(0.0001)`,
typeWanted: evalengine.NewTypeEx(sqltypes.Decimal, collations.CollationBinaryID, false, 4, 4),
typeWanted: evalengine.NewTypeEx(sqltypes.Decimal, collations.CollationBinaryID, false, 4, 4, nil),
},
}

Expand Down Expand Up @@ -729,7 +729,7 @@ func TestCompilerSingle(t *testing.T) {
if tc.typeWanted.Type() != sqltypes.Unknown {
typ, err := env.TypeOf(converted)
require.NoError(t, err)
require.EqualValues(t, tc.typeWanted, typ)
require.True(t, tc.typeWanted.Equal(&typ))
}

// re-run the same evaluation multiple times to ensure results are always consistent
Expand Down

0 comments on commit e65487d

Please sign in to comment.