westonpace commented on code in PR #13028: URL: https://github.com/apache/arrow/pull/13028#discussion_r899553180
########## cpp/src/arrow/compute/exec/asof_join_node_test.cc: ########## @@ -0,0 +1,323 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include <gmock/gmock-matchers.h> + +#include <numeric> +#include <random> +#include <unordered_set> + +#include "arrow/api.h" +#include "arrow/compute/exec/options.h" +#include "arrow/compute/exec/test_util.h" +#include "arrow/compute/exec/util.h" +#include "arrow/compute/kernels/row_encoder.h" +#include "arrow/compute/kernels/test_util.h" +#include "arrow/testing/gtest_util.h" +#include "arrow/testing/matchers.h" +#include "arrow/testing/random.h" +#include "arrow/util/checked_cast.h" +#include "arrow/util/make_unique.h" +#include "arrow/util/thread_pool.h" + +using testing::UnorderedElementsAreArray; + +namespace arrow { +namespace compute { + +BatchesWithSchema GenerateBatchesFromString( + const std::shared_ptr<Schema>& schema, + const std::vector<util::string_view>& json_strings, int multiplicity = 1) { + BatchesWithSchema out_batches{{}, schema}; + + std::vector<ValueDescr> descrs; + for (auto&& field : schema->fields()) { + descrs.emplace_back(field->type()); + } + + for (auto&& s : json_strings) { + out_batches.batches.push_back(ExecBatchFromJSON(descrs, s)); + } + + size_t batch_count = out_batches.batches.size(); + for (int repeat = 1; repeat < multiplicity; ++repeat) { + for (size_t i = 0; i < batch_count; ++i) { + out_batches.batches.push_back(out_batches.batches[i]); + } + } + + return out_batches; +} + +void CheckRunOutput(const BatchesWithSchema& l_batches, + const BatchesWithSchema& r0_batches, + const BatchesWithSchema& r1_batches, + const BatchesWithSchema& exp_batches, const FieldRef time, + const FieldRef keys, const int64_t tolerance) { + auto exec_ctx = + arrow::internal::make_unique<ExecContext>(default_memory_pool(), nullptr); + ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_ctx.get())); + + AsofJoinNodeOptions join_options(time, keys, tolerance); + Declaration join{"asofjoin", join_options}; + + join.inputs.emplace_back(Declaration{ + "source", SourceNodeOptions{l_batches.schema, l_batches.gen(false, false)}}); + join.inputs.emplace_back(Declaration{ + "source", SourceNodeOptions{r0_batches.schema, r0_batches.gen(false, false)}}); + join.inputs.emplace_back(Declaration{ + "source", SourceNodeOptions{r1_batches.schema, r1_batches.gen(false, false)}}); Review Comment: My thinking was to leave the executor as `nullptr` but change things like `l_batches.gen(false, false)` to `l_batches.gen(false, true)`. Each input should still be ordered but since there is some delay there might be some variation in arrival order. I think right now you will always get (assuming two batches per input)... ``` l_batches::0 l_batches::1 l_batches::end r0_batches::0 r0_batches::1 r0_batches::end r1_batches::0 r1_batches::1 r1_batches::end ``` I was hoping it would be possible that adding slow could yield something like... ``` l_batches::0 r0_batches::0 l_batches::1 r1_batches::0 r0_batches::1 l_batches::end r0_batches::end r1_batches::1 r1_batches::end ``` However, if that is not what you are seeing, then we don't need to dig too deeply and can worry about it more when we add support for parallelism. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org