From fa8f5db050be436a14b2be2bc67128fb6c483957 Mon Sep 17 00:00:00 2001 From: Yahor Yuzefovich Date: Thu, 8 Apr 2021 19:49:47 -0700 Subject: [PATCH] colexec: clean up external distinct test a bit Release note: None --- pkg/sql/colexec/external_distinct_test.go | 32 +++++++++-------------- pkg/sql/colexec/external_sort_test.go | 3 --- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/pkg/sql/colexec/external_distinct_test.go b/pkg/sql/colexec/external_distinct_test.go index a2242483556e..1e265fc310c9 100644 --- a/pkg/sql/colexec/external_distinct_test.go +++ b/pkg/sql/colexec/external_distinct_test.go @@ -67,38 +67,35 @@ func TestExternalDistinct(t *testing.T) { for tcIdx, tc := range distinctTestCases { log.Infof(context.Background(), "spillForced=%t/%d", spillForced, tcIdx) var semsToCheck []semaphore.Semaphore + var outputOrdering execinfrapb.Ordering + verifier := colexectestutils.UnorderedVerifier + // Check that the external distinct and the disk-backed sort + // were added as Closers. + numExpectedClosers := 2 + if tc.isOrderedOnDistinctCols { + outputOrdering = convertDistinctColsToOrdering(tc.distinctCols) + verifier = colexectestutils.OrderedVerifier + // The final disk-backed sort must also be added as a + // Closer. + numExpectedClosers++ + } colexectestutils.RunTestsWithTyps( t, testAllocator, []colexectestutils.Tuples{tc.tuples}, [][]*types.T{tc.typs}, tc.expected, - // We're using an unordered verifier because the in-memory - // unordered distinct is free to change the order of the tuples - // when exporting them into an external distinct. - colexectestutils.UnorderedVerifier, + verifier, func(input []colexecop.Operator) (colexecop.Operator, error) { // A sorter should never exceed ExternalSorterMinPartitions, even // during repartitioning. A panic will happen if a sorter requests // more than this number of file descriptors. sem := colexecop.NewTestingSemaphore(colexecop.ExternalSorterMinPartitions) semsToCheck = append(semsToCheck, sem) - var outputOrdering execinfrapb.Ordering - if tc.isOrderedOnDistinctCols { - outputOrdering = convertDistinctColsToOrdering(tc.distinctCols) - } distinct, newAccounts, newMonitors, closers, err := createExternalDistinct( ctx, flowCtx, input, tc.typs, tc.distinctCols, outputOrdering, queueCfg, sem, nil /* spillingCallbackFn */, numForcedRepartitions, ) - // Check that the external distinct and the disk-backed sort - // were added as Closers. - numExpectedClosers := 2 - if len(outputOrdering.Columns) > 0 { - // The final disk-backed sort must also be added as a - // Closer. - numExpectedClosers++ - } require.Equal(t, numExpectedClosers, len(closers)) accounts = append(accounts, newAccounts...) monitors = append(monitors, newMonitors...) @@ -385,9 +382,6 @@ func createExternalDistinct( } args.TestingKnobs.SpillingCallbackFn = spillingCallbackFn args.TestingKnobs.NumForcedRepartitions = numForcedRepartitions - // External sorter relies on different memory accounts to - // understand when to start a new partition, so we will not use - // the streaming memory account. result, err := colexecargs.TestNewColOperator(ctx, flowCtx, args) return result.Op, result.OpAccounts, result.OpMonitors, result.ToClose, err } diff --git a/pkg/sql/colexec/external_sort_test.go b/pkg/sql/colexec/external_sort_test.go index 2d549729172c..3ddad4369053 100644 --- a/pkg/sql/colexec/external_sort_test.go +++ b/pkg/sql/colexec/external_sort_test.go @@ -487,9 +487,6 @@ func createDiskBackedSorter( DiskQueueCfg: diskQueueCfg, FDSemaphore: testingSemaphore, } - // External sorter relies on different memory accounts to - // understand when to start a new partition, so we will not use - // the streaming memory account. args.TestingKnobs.SpillingCallbackFn = spillingCallbackFn args.TestingKnobs.NumForcedRepartitions = numForcedRepartitions args.TestingKnobs.DelegateFDAcquisitions = delegateFDAcquisitions