wgtmac commented on code in PR #156:
URL: https://github.com/apache/iceberg-cpp/pull/156#discussion_r2262232472
##########
src/iceberg/transform_function.cc:
##########
@@ -148,14 +253,51 @@ Result<std::unique_ptr<TransformFunction>>
YearTransform::Make(
MonthTransform::MonthTransform(std::shared_ptr<Type> const& source_type)
: TransformFunction(TransformType::kMonth, source_type) {}
-Result<ArrowArray> MonthTransform::Transform(const ArrowArray& input) {
- return NotImplemented("MonthTransform::Transform");
-}
+Result<Literal> MonthTransform::Transform(const Literal& literal) {
+ assert(literal.type() == source_type());
+ if (literal.IsBelowMin() || literal.IsAboveMax()) {
+ return InvalidArgument(
+ "Cannot apply month transform to literal with value {} of type {}",
+ literal.ToString(), source_type()->ToString());
+ }
+ if (literal.IsNull()) [[unlikely]] {
+ return Literal::Null(iceberg::int32());
+ }
-Result<std::shared_ptr<Type>> MonthTransform::ResultType() const {
- return iceberg::int32();
+ using namespace std::chrono; // NOLINT
+ switch (source_type()->type_id()) {
+ case TypeId::kDate: {
+ auto value = std::get<int32_t>(literal.value());
Review Comment:
nit: I think we need also move all of these transform functions to a
dedicated utility file and add exhaustive test cases. Could you create an issue
for this?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]