Skip to content

Commit

Permalink
Things compiling again
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Jul 29, 2022
1 parent e6155f3 commit 6537e05
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 148 deletions.
5 changes: 2 additions & 3 deletions cpp/src/arrow/compute/kernels/aggregate_basic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,9 @@ void AddMinMaxKernel(KernelInit init, internal::detail::GetTypeId get_id,
AddAggKernel(std::move(sig), init, func, simd_level);
}

void AddMinMaxKernels(KernelInit init,
const std::vector<std::shared_ptr<DataType>>& types,
void AddMinMaxKernels(KernelInit init, const std::vector<const DataType*>& types,
ScalarAggregateFunction* func, SimdLevel::type simd_level) {
for (const auto& ty : types) {
for (const DataType* ty : types) {
AddMinMaxKernel(init, ty, func, simd_level);
}
}
Expand Down
14 changes: 6 additions & 8 deletions cpp/src/arrow/compute/kernels/aggregate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -942,12 +942,12 @@ class TestCountDistinctKernel : public ::testing::Test {
CheckScalar("count_distinct", {input}, Expected(expected_all), &all);
}

void Check(const std::shared_ptr<DataType>& type, util::string_view json,
int64_t expected_all, bool has_nulls = true) {
void Check(const TypeHolder& type, util::string_view json, int64_t expected_all,
bool has_nulls = true) {
Check(ArrayFromJSON(type, json), expected_all, has_nulls);
}

void Check(const std::shared_ptr<DataType>& type, util::string_view json) {
void Check(const TypeHolder& type, util::string_view json) {
auto input = ScalarFromJSON(type, json);
auto zero = ResultWith(Expected(0));
auto one = ResultWith(Expected(1));
Expand All @@ -962,11 +962,9 @@ class TestCountDistinctKernel : public ::testing::Test {
EXPECT_THAT(CallFunction("count_distinct", {input}, &all), one);
}

void CheckChunkedArr(const DataType* type,
const std::vector<std::string>& json, int64_t expected_all,
bool has_nulls = true) {
Check(ChunkedArrayFromJSON(type->GetSharedPtr(), json), expected_all,
has_nulls);
void CheckChunkedArr(const TypeHolder& type, const std::vector<std::string>& json,
int64_t expected_all, bool has_nulls = true) {
Check(ChunkedArrayFromJSON(type, json), expected_all, has_nulls);
}

CountOptions only_valid{CountOptions::ONLY_VALID};
Expand Down
93 changes: 49 additions & 44 deletions cpp/src/arrow/compute/kernels/hash_aggregate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1678,10 +1678,10 @@ TEST(GroupBy, MinMaxOnly) {
}

TEST(GroupBy, MinMaxTypes) {
std::vector<std::shared_ptr<DataType>> types;
std::vector<const DataType*> types;
types.insert(types.end(), NumericTypes().begin(), NumericTypes().end());
types.insert(types.end(), TemporalTypes().begin(), TemporalTypes().end());
types.push_back(month_interval());
types.push_back(month_interval().get());

const std::vector<std::string> default_table = {R"([
[1, 1],
Expand Down Expand Up @@ -1739,9 +1739,10 @@ TEST(GroupBy, MinMaxTypes) {
[{"min": 86400000, "max": 345600000}, null]
])";

for (const auto& ty : types) {
for (const DataType* ty : types) {
auto shared_ty = ty->GetSharedPtr();
SCOPED_TRACE(ty->ToString());
auto in_schema = schema({field("argument0", ty), field("key", int64())});
auto in_schema = schema({field("argument0", shared_ty), field("key", int64())});
auto table =
TableFromJSON(in_schema, (ty->name() == "date64") ? date64_table : default_table);

Expand All @@ -1754,12 +1755,12 @@ TEST(GroupBy, MinMaxTypes) {
SortBy({"key_0"}, &aggregated_and_grouped);

AssertDatumsEqual(
ArrayFromJSON(
struct_({
field("hash_min_max", struct_({field("min", ty), field("max", ty)})),
field("key_0", int64()),
}),
(ty->name() == "date64") ? date64_expected : default_expected),
ArrayFromJSON(struct_({
field("hash_min_max", struct_({field("min", shared_ty),
field("max", shared_ty)})),
field("key_0", int64()),
}),
(ty->name() == "date64") ? date64_expected : default_expected),
aggregated_and_grouped,
/*verbose=*/true);
}
Expand Down Expand Up @@ -1837,11 +1838,11 @@ TEST(GroupBy, MinMaxDecimal) {
TEST(GroupBy, MinMaxBinary) {
for (bool use_exec_plan : {false, true}) {
for (bool use_threads : {true, false}) {
for (const auto& ty : BaseBinaryTypes()) {
for (const DataType* ty : BaseBinaryTypes()) {
SCOPED_TRACE(use_threads ? "parallel/merged" : "serial");

auto table = TableFromJSON(schema({
field("argument0", ty),
field("argument0", ty->GetSharedPtr()),
field("key", int64()),
}),
{R"([
Expand Down Expand Up @@ -1869,13 +1870,14 @@ TEST(GroupBy, MinMaxBinary) {
ValidateOutput(aggregated_and_grouped);
SortBy({"key_0"}, &aggregated_and_grouped);

auto shared_ty = ty->GetSharedPtr();
AssertDatumsEqual(
ArrayFromJSON(
struct_({
field("hash_min_max", struct_({field("min", ty), field("max", ty)})),
field("key_0", int64()),
}),
R"([
ArrayFromJSON(struct_({
field("hash_min_max", struct_({field("min", shared_ty),
field("max", shared_ty)})),
field("key_0", int64()),
}),
R"([
[{"min": "aaaa", "max": "d"}, 1],
[{"min": "babcd", "max": "bcd"}, 2],
[{"min": null, "max": null}, 3],
Expand Down Expand Up @@ -2609,10 +2611,10 @@ TEST(GroupBy, OneMiscTypes) {
}

TEST(GroupBy, OneNumericTypes) {
std::vector<std::shared_ptr<DataType>> types;
std::vector<const DataType*> types;
types.insert(types.end(), NumericTypes().begin(), NumericTypes().end());
types.insert(types.end(), TemporalTypes().begin(), TemporalTypes().end());
types.push_back(month_interval());
types.push_back(month_interval().get());

const std::vector<std::string> numeric_table_json = {R"([
[null, 1],
Expand Down Expand Up @@ -2652,11 +2654,12 @@ TEST(GroupBy, OneNumericTypes) {
[null, 3]
])"};

for (const auto& type : types) {
for (const DataType* type : types) {
for (bool use_exec_plan : {true, false}) {
for (bool use_threads : {true, false}) {
auto shared_ty = type->GetSharedPtr();
SCOPED_TRACE(type->ToString());
auto in_schema = schema({field("argument0", type), field("key", int64())});
auto in_schema = schema({field("argument0", shared_ty), field("key", int64())});
auto table =
TableFromJSON(in_schema, (type->name() == "date64") ? temporal_table_json
: numeric_table_json);
Expand Down Expand Up @@ -2699,11 +2702,11 @@ TEST(GroupBy, OneNumericTypes) {
TEST(GroupBy, OneBinaryTypes) {
for (bool use_exec_plan : {true, false}) {
for (bool use_threads : {true, false}) {
for (const auto& type : BaseBinaryTypes()) {
for (const DataType* type : BaseBinaryTypes()) {
SCOPED_TRACE(use_threads ? "parallel/merged" : "serial");

auto table = TableFromJSON(schema({
field("argument0", type),
field("argument0", type->GetSharedPtr()),
field("key", int64()),
}),
{R"([
Expand Down Expand Up @@ -2778,38 +2781,39 @@ TEST(GroupBy, OneScalar) {
}

TEST(GroupBy, ListNumeric) {
for (const auto& type : NumericTypes()) {
for (const DataType* type : NumericTypes()) {
for (auto use_threads : {true, false}) {
SCOPED_TRACE(use_threads ? "parallel/merged" : "serial");
{
SCOPED_TRACE("with nulls");
auto table =
TableFromJSON(schema({field("argument", type), field("key", int64())}), {R"([
auto table = TableFromJSON(
schema({field("argument", type->GetSharedPtr()), field("key", int64())}),
{R"([
[99, 1],
[99, 1]
])",
R"([
R"([
[88, 2],
[null, 3],
[null, 3]
])",
R"([
R"([
[null, 4],
[null, 4]
])",
R"([
R"([
[77, null],
[99, 3]
])",
R"([
R"([
[88, 2],
[66, 2]
])",
R"([
R"([
[55, null],
[44, 3]
])",
R"([
R"([
[33, null],
[22, null]
])"});
Expand Down Expand Up @@ -2854,33 +2858,34 @@ TEST(GroupBy, ListNumeric) {
}
{
SCOPED_TRACE("without nulls");
auto table =
TableFromJSON(schema({field("argument", type), field("key", int64())}), {R"([
auto table = TableFromJSON(
schema({field("argument", type->GetSharedPtr()), field("key", int64())}),
{R"([
[99, 1],
[99, 1]
])",
R"([
R"([
[88, 2],
[100, 3],
[100, 3]
])",
R"([
R"([
[86, 4],
[86, 4]
])",
R"([
R"([
[77, null],
[99, 3]
])",
R"([
R"([
[88, 2],
[66, 2]
])",
R"([
R"([
[55, null],
[44, 3]
])",
R"([
R"([
[33, null],
[22, null]
])"});
Expand Down Expand Up @@ -2929,12 +2934,12 @@ TEST(GroupBy, ListNumeric) {

TEST(GroupBy, ListBinaryTypes) {
for (bool use_threads : {true, false}) {
for (const auto& type : BaseBinaryTypes()) {
for (const DataType* type : BaseBinaryTypes()) {
SCOPED_TRACE(use_threads ? "parallel/merged" : "serial");
{
SCOPED_TRACE("with nulls");
auto table = TableFromJSON(schema({
field("argument0", type),
field("argument0", type->GetSharedPtr()),
field("key", int64()),
}),
{R"([
Expand Down Expand Up @@ -2996,7 +3001,7 @@ TEST(GroupBy, ListBinaryTypes) {
{
SCOPED_TRACE("without nulls");
auto table = TableFromJSON(schema({
field("argument0", type),
field("argument0", type->GetSharedPtr()),
field("key", int64()),
}),
{R"([
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/compute/kernels/scalar_cast_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2235,8 +2235,7 @@ static void CheckStructToStruct(const std::vector<const DataType*>& value_types)
}
}

static void CheckStructToStructSubset(
const std::vector<const DataType*>& value_types) {
static void CheckStructToStructSubset(const std::vector<const DataType*>& value_types) {
for (const DataType* src_value_type : value_types) {
ARROW_SCOPED_TRACE("From type: ", src_value_type->ToString());
for (const DataType* dest_value_type : value_types) {
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/compute/kernels/scalar_nested_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
namespace arrow {
namespace compute {

static std::shared_ptr<DtaType> GetOffsetType(const DataType& type) {
static std::shared_ptr<DataType> GetOffsetType(const DataType& type) {
return type.id() == Type::LIST ? int32() : int64();
}

Expand All @@ -46,8 +46,8 @@ TEST(TestScalarNested, ListValueLength) {

TEST(TestScalarNested, ListElementNonFixedListWithNulls) {
auto sample = "[[7, 5, 81], [6, null, 4, 7, 8], [3, 12, 2, 0], [1, 9], null]";
for (auto ty : NumericTypes()) {
for (auto list_type : {list(ty), large_list(ty)}) {
for (const DataType* ty : NumericTypes()) {
for (auto list_type : {list(ty->GetSharedPtr()), large_list(ty->GetSharedPtr())}) {
auto input = ArrayFromJSON(list_type, sample);
auto null_input = ArrayFromJSON(list_type, "[null]");
for (auto index_type : IntTypes()) {
Expand All @@ -64,7 +64,7 @@ TEST(TestScalarNested, ListElementNonFixedListWithNulls) {
TEST(TestScalarNested, ListElementFixedList) {
auto sample = "[[7, 5, 81], [6, 4, 8], [3, 12, 2], [1, 43, 87]]";
for (auto ty : NumericTypes()) {
auto input = ArrayFromJSON(fixed_size_list(ty, 3), sample);
auto input = ArrayFromJSON(fixed_size_list(ty->GetSharedPtr(), 3), sample);
for (auto index_type : IntTypes()) {
auto index = ScalarFromJSON(index_type, "0");
auto expected = ArrayFromJSON(ty, "[7, 6, 3, 1]");
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/scalar_string_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ TYPED_TEST(TestStringKernels, BinaryRepeatWithScalarRepeat) {
for (const auto& pair : nrepeats_and_expected) {
auto num_repeat = pair.first;
auto expected = pair.second;
for (const auto& ty : IntTypes()) {
for (const DataType* ty : IntTypes()) {
this->CheckVarArgs("binary_repeat",
{values, Datum(*arrow::MakeScalar(ty, num_repeat))},
this->type(), expected);
Expand Down
1 change: 1 addition & 0 deletions cpp/src/arrow/compute/kernels/scalar_validity_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "arrow/array.h"
#include "arrow/compute/api.h"
#include "arrow/compute/kernels/common.h"
#include "arrow/compute/kernels/test_util.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/testing/random.h"
Expand Down
Loading

0 comments on commit 6537e05

Please sign in to comment.