Skip to content

Commit

Permalink
Make aggregation operators printable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexowens90 committed Apr 18, 2024
1 parent 21a295d commit 855f315
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cpp/arcticdb/processing/aggregation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ Column SortedAggregator<aggregation_operator, closed_boundary>::aggregate(const
(aggregation_operator == SortedAggregationOperator::FIRST ||
aggregation_operator == SortedAggregationOperator::LAST ||
aggregation_operator == SortedAggregationOperator::COUNT)),
"Resample: Unsupported aggregation type on column '{}' of type {}",
get_input_column_name().value, input_data_type);
"Resample: Unsupported aggregation type {} on column '{}' of type {}",
aggregation_operator, get_input_column_name().value, input_data_type);
add_data_type_impl(input_data_type, output_data_type);
}
}
Expand Down
29 changes: 29 additions & 0 deletions cpp/arcticdb/processing/aggregation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,32 @@ class SortedAggregator
};

} //namespace arcticdb

namespace fmt {
template<>
struct formatter<arcticdb::SortedAggregationOperator> {
template<typename ParseContext>
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }

template<typename FormatContext>
auto format(const arcticdb::SortedAggregationOperator& agg, FormatContext &ctx) const {
switch(agg) {
case arcticdb::SortedAggregationOperator::SUM:
return fmt::format_to(ctx.out(), "SUM");
case arcticdb::SortedAggregationOperator::MEAN:
return fmt::format_to(ctx.out(), "MEAN");
case arcticdb::SortedAggregationOperator::MIN:
return fmt::format_to(ctx.out(), "MIN");
case arcticdb::SortedAggregationOperator::MAX:
return fmt::format_to(ctx.out(), "MAX");
case arcticdb::SortedAggregationOperator::FIRST:
return fmt::format_to(ctx.out(), "FIRST");
case arcticdb::SortedAggregationOperator::LAST:
return fmt::format_to(ctx.out(), "LAST");
case arcticdb::SortedAggregationOperator::COUNT:
default:
return fmt::format_to(ctx.out(), "COUNT");
}
}
};
} //namespace fmt
2 changes: 1 addition & 1 deletion python/tests/unit/arcticdb/version_store/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_resampling_string_columns_unsupported_aggregations(lmdb_version_store_v
for agg in ["sum", "mean", "min", "max"]:
q = QueryBuilder()
q = q.resample("min").agg({"col": agg})
with pytest.raises(SchemaException) as e:
with pytest.raises(SchemaException):
lib.read(sym, query_builder=q)


Expand Down

0 comments on commit 855f315

Please sign in to comment.