lidavidm commented on a change in pull request #12136:
URL: https://github.com/apache/arrow/pull/12136#discussion_r791745928
##########
File path: cpp/src/arrow/compute/kernels/codegen_internal.cc
##########
@@ -109,6 +109,39 @@ void ReplaceNullWithOtherType(ValueDescr* first, size_t
count) {
}
}
+void ReplaceTemporalTypes(const TimeUnit::type unit, std::vector<ValueDescr>*
descrs) {
+ auto* end = descrs->data() + descrs->size();
+ const std::string* timezone = nullptr;
+
+ for (auto* it = descrs->data(); it != end; it++) {
+ switch (it->type->id()) {
+ case Type::TIMESTAMP: {
+ const auto& ty = checked_cast<const TimestampType&>(*it->type);
+ timezone = &ty.timezone();
+ if (timezone) {
+ it->type = timestamp(unit, *timezone);
+ } else {
+ it->type = timestamp(unit);
+ }
+ continue;
+ }
+ case Type::TIME32:
+ case Type::TIME64:
+ case Type::DURATION: {
+ it->type = duration(unit);
+ continue;
+ }
+ case Type::DATE32:
+ case Type::DATE64: {
+ it->type = timestamp(unit);
Review comment:
Wait, shouldn't this be `date32`/`date64`?
##########
File path: cpp/src/arrow/compute/kernels/codegen_internal.cc
##########
@@ -109,6 +109,39 @@ void ReplaceNullWithOtherType(ValueDescr* first, size_t
count) {
}
}
+void ReplaceTemporalTypes(const TimeUnit::type unit, std::vector<ValueDescr>*
descrs) {
+ auto* end = descrs->data() + descrs->size();
+ const std::string* timezone = nullptr;
+
+ for (auto* it = descrs->data(); it != end; it++) {
+ switch (it->type->id()) {
+ case Type::TIMESTAMP: {
+ const auto& ty = checked_cast<const TimestampType&>(*it->type);
+ timezone = &ty.timezone();
+ if (timezone) {
+ it->type = timestamp(unit, *timezone);
+ } else {
+ it->type = timestamp(unit);
+ }
Review comment:
Can't this just be `it->type = timestamp(unit, ty.timezone())`? Since
`timezone()` is empty string for naive timestamps (not nullptr)
##########
File path: cpp/src/arrow/compute/kernels/codegen_internal.cc
##########
@@ -109,6 +109,39 @@ void ReplaceNullWithOtherType(ValueDescr* first, size_t
count) {
}
}
+void ReplaceTemporalTypes(const TimeUnit::type unit, std::vector<ValueDescr>*
descrs) {
+ auto* end = descrs->data() + descrs->size();
+ const std::string* timezone = nullptr;
+
+ for (auto* it = descrs->data(); it != end; it++) {
+ switch (it->type->id()) {
+ case Type::TIMESTAMP: {
+ const auto& ty = checked_cast<const TimestampType&>(*it->type);
+ timezone = &ty.timezone();
+ if (timezone) {
+ it->type = timestamp(unit, *timezone);
+ } else {
+ it->type = timestamp(unit);
+ }
+ continue;
+ }
+ case Type::TIME32:
+ case Type::TIME64:
+ case Type::DURATION: {
+ it->type = duration(unit);
+ continue;
+ }
+ case Type::DATE32:
+ case Type::DATE64: {
+ it->type = timestamp(unit);
Review comment:
Ah, okay. I guess this is kind of specific to temporal arithmetic.
--
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]