Skip to content

Commit

Permalink
ARROW-4198: [Gandiva] Added support to cast timestamp
Browse files Browse the repository at this point in the history
Added howard hinnant date project as a third party library.
Used system timezone database for timezone information.

Author: Antoine Pitrou <[email protected]>
Author: shyam <[email protected]>

Closes apache#3352 from shyambits2004/timestamp and squashes the following commits:

882a5cf <Antoine Pitrou> Tweak wording of vendored date library README
7f52480 <Antoine Pitrou> Small tweaks to license wording for the date library
9ee8eff <shyam> ARROW-4198 :  Added support to cast timestamp
  • Loading branch information
pitrou committed Jan 31, 2019
1 parent aa43784 commit 641c699
Show file tree
Hide file tree
Showing 23 changed files with 15,165 additions and 6,579 deletions.
6 changes: 5 additions & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,11 @@ See the License for the specific language governing permissions and
limitations under the License.

--------------------------------------------------------------------------------
The file cpp/src/arrow/vendored/date.h has the following license (MIT)
The files cpp/src/arrow/vendored/datetime/date.h, cpp/src/arrow/vendored/datetime/tz.h,
cpp/src/arrow/vendored/datetime/tz_private.h, cpp/src/arrow/vendored/datetime/ios.h,
cpp/src/arrow/vendored/datetime/tz.cpp are adapted from
Howard Hinnant's date library (https://github.com/HowardHinnant/date)
It is licensed under MIT license.

The MIT License (MIT)
Copyright (c) 2015, 2016, 2017 Howard Hinnant
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ set(ARROW_SRCS
util/thread-pool.cc
util/trie.cc
util/utf8.cc

vendored/datetime/tz.cpp
)

if ("${COMPILER_FAMILY}" STREQUAL "clang")
Expand Down
13 changes: 7 additions & 6 deletions cpp/src/arrow/util/parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "arrow/type.h"
#include "arrow/type_traits.h"
#include "arrow/util/checked_cast.h"
#include "arrow/vendored/date.h"
#include "arrow/vendored/datetime/date.h"

namespace arrow {
namespace internal {
Expand Down Expand Up @@ -375,15 +375,15 @@ class StringConverter<TimestampType> {
// - "YYYY-MM-DD[ T]hh:mm:ss"
// - "YYYY-MM-DD[ T]hh:mm:ssZ"
// UTC is always assumed, and the DataType's timezone is ignored.
date::year_month_day ymd;
arrow::util::date::year_month_day ymd;
if (ARROW_PREDICT_FALSE(length < 10)) {
return false;
}
if (length == 10) {
if (ARROW_PREDICT_FALSE(!ParseYYYY_MM_DD(s, &ymd))) {
return false;
}
return ConvertTimePoint(date::sys_days(ymd), out);
return ConvertTimePoint(arrow::util::date::sys_days(ymd), out);
}
if (ARROW_PREDICT_FALSE(s[10] != ' ') && ARROW_PREDICT_FALSE(s[10] != 'T')) {
return false;
Expand All @@ -399,7 +399,7 @@ class StringConverter<TimestampType> {
if (ARROW_PREDICT_FALSE(!ParseHH_MM_SS(s + 11, &seconds))) {
return false;
}
return ConvertTimePoint(date::sys_days(ymd) + seconds, out);
return ConvertTimePoint(arrow::util::date::sys_days(ymd) + seconds, out);
}
return false;
}
Expand Down Expand Up @@ -428,7 +428,7 @@ class StringConverter<TimestampType> {
return true;
}

bool ParseYYYY_MM_DD(const char* s, date::year_month_day* out) {
bool ParseYYYY_MM_DD(const char* s, arrow::util::date::year_month_day* out) {
uint16_t year;
uint8_t month, day;
if (ARROW_PREDICT_FALSE(s[4] != '-') || ARROW_PREDICT_FALSE(s[7] != '-')) {
Expand All @@ -443,7 +443,8 @@ class StringConverter<TimestampType> {
if (ARROW_PREDICT_FALSE(!detail::ParseUnsigned(s + 8, 2, &day))) {
return false;
}
*out = {date::year{year}, date::month{month}, date::day{day}};
*out = {arrow::util::date::year{year}, arrow::util::date::month{month},
arrow::util::date::day{day}};
return out->ok();
}

Expand Down
Loading

0 comments on commit 641c699

Please sign in to comment.