Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: fix panic while call Column.VecEvalInt #13401

Merged
merged 5 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion expression/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (col *Column) Equal(_ sessionctx.Context, expr Expression) bool {
func (col *Column) VecEvalInt(ctx sessionctx.Context, input *chunk.Chunk, result *chunk.Column) error {
if col.RetType.Hybrid() {
it := chunk.NewIterator4Chunk(input)
result.Reset()
result.ResizeInt64(0, false)
for row := it.Begin(); row != it.End(); row = it.Next() {
v, null, err := col.EvalInt(ctx, row)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion expression/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (s *testEvaluatorSuite) TestColHybird(c *C) {
c.Assert(err, IsNil)
input.AppendBytes(0, num)
}
result, err := newBuffer(types.ETInt, 1024)
result, err := newBuffer(types.ETString, 1024)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add an annotation to explain why use VecEvalInt but type is ETString here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should keep this regular test and add a new specific case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case can be triggered if the result chunk.Chunk has a different field type with Int.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it, but it is not intuitive for the first-time code reader.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments addressed

c.Assert(err, IsNil)
c.Assert(col.VecEvalInt(ctx, input, result), IsNil)

Expand Down