You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/04/26 12:25:01 UTC
[GitHub] [arrow] DileepSrigiri opened a new pull request #10160: [C++][Gandiva] Add space,add_months and datediff functions for string
DileepSrigiri opened a new pull request #10160:
URL: https://github.com/apache/arrow/pull/10160
Add space,add_months and datediff functions for string in Gandiva
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] projjal commented on a change in pull request #10160: ARROW-12563: [C++][Gandiva] Add space,add_months and datediff functions for string
Posted by GitBox <gi...@apache.org>.
projjal commented on a change in pull request #10160:
URL: https://github.com/apache/arrow/pull/10160#discussion_r629859574
##########
File path: cpp/src/gandiva/precompiled/epoch_time_point.h
##########
@@ -19,6 +19,14 @@
// TODO(wesm): IR compilation does not have any include directories set
#include "../../arrow/vendored/datetime/date.h"
+#ifndef UTIL_FUNCTIONS
Review comment:
what use of this #ifndef?
##########
File path: cpp/src/gandiva/precompiled/timestamp_arithmetic.cc
##########
@@ -170,17 +194,41 @@ TIMESTAMP_DIFF(timestamp)
FORCE_INLINE \
gdv_##TYPE NAME##_##TYPE##_int64(gdv_##TYPE millis, gdv_int64 count) { \
return millis + TO_MILLIS * static_cast<gdv_##TYPE>(count); \
+ }
+
+
+#define ADD_TIMESTAMP_TO_INT32_MONTH_UNITS(TYPE, NAME, N_MONTHS) \
+ FORCE_INLINE \
+ gdv_##TYPE NAME##_##TYPE##_int32(gdv_##TYPE millis, gdv_int32 count) { \
+ EpochTimePoint tp(millis); \
+ return tp.AddMonths(static_cast<int>(count * N_MONTHS)).MillisSinceEpoch(); \
+ }
+
+#define ADD_TIMESTAMP_TO_INT64_MONTH_UNITS(TYPE, NAME, N_MONTHS) \
+ FORCE_INLINE \
+ gdv_##TYPE NAME##_##TYPE##_int64(gdv_##TYPE millis, gdv_int64 count) { \
+ EpochTimePoint tp(millis); \
+ return tp.AddMonths(static_cast<int>(count * N_MONTHS)).MillisSinceEpoch(); \
}
#define TIMESTAMP_ADD_INT32(TYPE) \
ADD_INT32_TO_TIMESTAMP_FIXED_UNITS(TYPE, timestampaddSecond, MILLIS_IN_SEC) \
+ ADD_TIMESTAMP_TO_INT32_FIXED_UNITS(TYPE, timestampaddSecond, MILLIS_IN_SEC) \
Review comment:
nit: add a macro ADD_TIMESTAMP_INT32 which calls ADD_TIMESTAMP_TO_INT32 and ADD_INT32_TO_TIMESTAMP
##########
File path: cpp/src/gandiva/precompiled/epoch_time_point.h
##########
@@ -65,12 +73,22 @@ class EpochTimePoint {
.time_since_epoch());
}
- EpochTimePoint AddMonths(int num_months) const {
- auto ymd = YearMonthDay() + arrow_vendored::date::months(num_months);
- return EpochTimePoint((arrow_vendored::date::sys_days{ymd} + // NOLINT
- TimeOfDay().to_duration())
- .time_since_epoch());
- }
+ EpochTimePoint AddMonths(int num_months) const {
+ auto ymd = YearMonthDay() + arrow_vendored::date::months(num_months);
+
+ EpochTimePoint tp = EpochTimePoint((arrow_vendored::date::sys_days{ymd} + // NOLINT
+ TimeOfDay().to_duration())
+ .time_since_epoch());
+
+ if(did_days_overflow(static_cast<int>(ymd.year()), static_cast<unsigned int>(ymd.month()),
Review comment:
nit: better pass `date::year_month_day` as argument
##########
File path: cpp/src/gandiva/precompiled/timestamp_arithmetic.cc
##########
@@ -47,6 +47,28 @@ bool is_last_day_of_month(const EpochTimePoint& tp) {
return !is_leap_year(tp.TmYear());
}
+bool did_days_overflow(int year, int month, int days) {
+ int days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
Review comment:
you can set a static days_in_month array
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] DileepSrigiri closed pull request #10160: ARROW-12563: [C++][Gandiva] Add space,add_months and datediff functions for string
Posted by GitBox <gi...@apache.org>.
DileepSrigiri closed pull request #10160:
URL: https://github.com/apache/arrow/pull/10160
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] DileepSrigiri commented on a change in pull request #10160: ARROW-12563: [C++][Gandiva] Add space,add_months and datediff functions for string
Posted by GitBox <gi...@apache.org>.
DileepSrigiri commented on a change in pull request #10160:
URL: https://github.com/apache/arrow/pull/10160#discussion_r630083819
##########
File path: cpp/src/gandiva/precompiled/epoch_time_point.h
##########
@@ -19,6 +19,14 @@
// TODO(wesm): IR compilation does not have any include directories set
#include "../../arrow/vendored/datetime/date.h"
+#ifndef UTIL_FUNCTIONS
Review comment:
removed it
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] DileepSrigiri commented on pull request #10160: ARROW-12563: [C++][Gandiva] Add space,add_months and datediff functions for string
Posted by GitBox <gi...@apache.org>.
DileepSrigiri commented on pull request #10160:
URL: https://github.com/apache/arrow/pull/10160#issuecomment-884655154
Functions were already added
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] DileepSrigiri commented on a change in pull request #10160: ARROW-12563: [C++][Gandiva] Add space,add_months and datediff functions for string
Posted by GitBox <gi...@apache.org>.
DileepSrigiri commented on a change in pull request #10160:
URL: https://github.com/apache/arrow/pull/10160#discussion_r630087656
##########
File path: cpp/src/gandiva/precompiled/timestamp_arithmetic.cc
##########
@@ -47,6 +47,28 @@ bool is_last_day_of_month(const EpochTimePoint& tp) {
return !is_leap_year(tp.TmYear());
}
+bool did_days_overflow(int year, int month, int days) {
+ int days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
Review comment:
Done
##########
File path: cpp/src/gandiva/precompiled/epoch_time_point.h
##########
@@ -65,12 +73,22 @@ class EpochTimePoint {
.time_since_epoch());
}
- EpochTimePoint AddMonths(int num_months) const {
- auto ymd = YearMonthDay() + arrow_vendored::date::months(num_months);
- return EpochTimePoint((arrow_vendored::date::sys_days{ymd} + // NOLINT
- TimeOfDay().to_duration())
- .time_since_epoch());
- }
+ EpochTimePoint AddMonths(int num_months) const {
+ auto ymd = YearMonthDay() + arrow_vendored::date::months(num_months);
+
+ EpochTimePoint tp = EpochTimePoint((arrow_vendored::date::sys_days{ymd} + // NOLINT
+ TimeOfDay().to_duration())
+ .time_since_epoch());
+
+ if(did_days_overflow(static_cast<int>(ymd.year()), static_cast<unsigned int>(ymd.month()),
Review comment:
Done
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] github-actions[bot] commented on pull request #10160: ARROW-12563: [C++][Gandiva] Add space,add_months and datediff functions for string
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10160:
URL: https://github.com/apache/arrow/pull/10160#issuecomment-827323885
https://issues.apache.org/jira/browse/ARROW-12563
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] github-actions[bot] commented on pull request #10160: [C++][Gandiva] Add space,add_months and datediff functions for string
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10160:
URL: https://github.com/apache/arrow/pull/10160#issuecomment-826793394
<!--
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.
-->
Thanks for opening a pull request!
If this is not a [minor PR](https://github.com/apache/arrow/blob/master/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on JIRA? https://issues.apache.org/jira/browse/ARROW
Opening JIRAs ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
Then could you also rename pull request title in the following format?
ARROW-${JIRA_ID}: [${COMPONENT}] ${SUMMARY}
or
MINOR: [${COMPONENT}] ${SUMMARY}
See also:
* [Other pull requests](https://github.com/apache/arrow/pulls/)
* [Contribution Guidelines - How to contribute patches](https://arrow.apache.org/docs/developers/contributing.html#how-to-contribute-patches)
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] projjal commented on a change in pull request #10160: ARROW-12563: [C++][Gandiva] Add space,add_months and datediff functions for string
Posted by GitBox <gi...@apache.org>.
projjal commented on a change in pull request #10160:
URL: https://github.com/apache/arrow/pull/10160#discussion_r626688195
##########
File path: cpp/src/gandiva/function_registry_timestamp_arithmetic.cc
##########
@@ -58,13 +64,15 @@ std::vector<NativeFunction> GetDateTimeArithmeticFunctionRegistry() {
TIMESTAMP_DIFF_FN(timestampdiffMonth, {}),
TIMESTAMP_DIFF_FN(timestampdiffQuarter, {}),
TIMESTAMP_DIFF_FN(timestampdiffYear, {}),
+ TIMESTAMP_DIFF_FN(datediff, {}),
Review comment:
please add datediff and add_months as aliases
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] projjal commented on pull request #10160: ARROW-12563: [C++][Gandiva] Add space,add_months and datediff functions for string
Posted by GitBox <gi...@apache.org>.
projjal commented on pull request #10160:
URL: https://github.com/apache/arrow/pull/10160#issuecomment-838492412
The CI builds are failing.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] projjal commented on pull request #10160: ARROW-12563: [C++][Gandiva] Add space,add_months and datediff functions for string
Posted by GitBox <gi...@apache.org>.
projjal commented on pull request #10160:
URL: https://github.com/apache/arrow/pull/10160#issuecomment-837881124
Can you add a description comment in the PR about the functions.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org