Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Check if eval buffer is empty. #491

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Check if eval buffer is empty.
Signed-off-by: kuba-- <kuba@sourced.tech>
  • Loading branch information
kuba-- committed Oct 22, 2018
commit 1c3037c63d4bbcc889e0e4e57a28497e6afe3a37
5 changes: 4 additions & 1 deletion sql/plan/group_by.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,10 @@ func evalBuffer(
case *expression.Alias:
return evalBuffer(ctx, n.Child, buffer)
case *expression.GetField:
return buffer[0], nil
if len(buffer) > 0 {
return buffer[0], nil
}
return nil, nil
default:
return nil, ErrGroupBy.New(n.String())
}
Expand Down
9 changes: 9 additions & 0 deletions sql/plan/group_by_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ func TestGroupBy_RowIter(t *testing.T) {
require.Equal(sql.NewRow("col1_2", int64(4444)), rows[1])
}

func TestGroupBy_EvalEmptyBuffer(t *testing.T) {
require := require.New(t)
ctx := sql.NewEmptyContext()

r, err := evalBuffer(ctx, expression.NewGetField(0, sql.Text, "col1", true), sql.Row{})
require.NoError(err)
require.Nil(r)
}

func TestGroupBy_Error(t *testing.T) {
require := require.New(t)
ctx := sql.NewEmptyContext()
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy