Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
Signed-off-by: arenatlx <314806019@qq.com>
  • Loading branch information
AilinKid committed Nov 28, 2024
1 parent 70f5218 commit ba661e1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/planner/core/operator/logicalop/logical_max_one_row.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import (

// LogicalMaxOneRow checks if a query returns no more than one row.
type LogicalMaxOneRow struct {
BaseLogicalPlan
// logical max one row, doesn't have any other attribute to distinguish, use plan id inside.
BaseLogicalPlan `hash64-equals:"true"`
}

// Init initializes LogicalMaxOneRow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,21 @@ func TestLogicalSchemaProducerHash64Equals(t *testing.T) {
}

func TestLogicalMaxOneRowHash64Equals(t *testing.T) {
m1 := &logicalop.LogicalMaxOneRow{}
m2 := &logicalop.LogicalMaxOneRow{}
ctx := mock.NewContext()
m1 := logicalop.LogicalMaxOneRow{}.Init(ctx, 1)
m2 := logicalop.LogicalMaxOneRow{}.Init(ctx, 1)
// since logical max one row doesn't have any elements, they are always indicate
// that they are equal.
hasher1 := base.NewHashEqualer()
hasher2 := base.NewHashEqualer()
m1.Hash64(hasher1)
m2.Hash64(hasher2)
require.NotEqual(t, hasher1.Sum64(), hasher2.Sum64())
require.False(t, m1.Equals(m2))

m2.SetID(m1.ID())
hasher2.Reset()
m2.Hash64(hasher2)
require.Equal(t, hasher1.Sum64(), hasher2.Sum64())
require.True(t, m1.Equals(m2))
}
Expand Down

0 comments on commit ba661e1

Please sign in to comment.