Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timestamp parser to parse timestamp string with time zone #1539

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b15c762
Add timestamp parser
Nov 5, 2023
73e0f7e
Refine parser
Dec 12, 2023
df60772
Update
Dec 12, 2023
a4a83c0
Update
Dec 12, 2023
89eef6b
Fix bitmask; Parse special timestamp strings: now, today ...; Add Ans…
Dec 14, 2023
533f590
Format code
Dec 14, 2023
759a6dc
Update for UTC time zone parser
Dec 14, 2023
3335201
Add JNI interface
Dec 14, 2023
2270d8b
complete the work
sperlingxx Dec 27, 2023
7c9b800
refine
sperlingxx Jan 10, 2024
93d4a66
fix clang-fmt
sperlingxx Jan 10, 2024
2cf4940
Copyrights;typos
Jan 11, 2024
8eff534
Fix compile error; Update comments
Jan 11, 2024
5dbc7eb
Remove supports for cast special strings(epoch now today yesterday to…
Jan 12, 2024
167df50
Add comments
Jan 12, 2024
ec1c686
Add comments; Add test cases
Jan 15, 2024
3cba7d0
Address comments
Jan 15, 2024
e6af195
Fix case
Jan 15, 2024
0b33ff9
Update
Jan 15, 2024
a8fc54c
Support short time zone IDs, like PST, CTT......
Jan 15, 2024
10eba22
Format code
Jan 15, 2024
24e81cd
Update comments
Jan 16, 2024
374dede
Update comments
Jan 18, 2024
1d0ef4c
Address comments
Jan 22, 2024
b875840
Address comments
Jan 23, 2024
93a8331
Fixes; Comments
Jan 24, 2024
36da155
Merge branch-24.02
Jan 24, 2024
c8dffb1
Refector GpuTimeZoneDB; Add comment for year has max 6 digits
Jan 25, 2024
4104173
format cpp code
Jan 25, 2024
5af012c
Remove .clang-format
Jan 25, 2024
97a8f8f
Fix do not support non-normalized time zone, like: Etc/GMT; Optimize …
Jan 25, 2024
0a7efd9
Refector to address comments
Jan 26, 2024
f947fbd
Merge branch 'branch-24.02' into timestamp-parser
Jan 26, 2024
21f99db
Fix cases
Jan 26, 2024
6ddb91c
Fix cudaErrorIllegalAddress error; Fix null pointer bug
Jan 26, 2024
863cb83
Update comments
Jan 26, 2024
de74645
Refactor
Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-2024, NVIDIA CORPORATION.
#
# Licensed 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
Expand Down Expand Up @@ -165,6 +165,7 @@ add_library(
src/cast_float_to_string.cu
src/cast_string.cu
src/cast_string_to_float.cu
src/datetime_parser.cu
src/datetime_rebase.cu
src/decimal_utils.cu
src/histogram.cu
Expand Down
56 changes: 55 additions & 1 deletion src/main/cpp/src/CastStringJni.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
* Copyright (c) 2022-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,6 +30,7 @@
#include <cudf/unary.hpp>

#include "cudf_jni_apis.hpp"
#include "datetime_parser.hpp"
#include "dtype_utils.hpp"
#include "jni_utils.hpp"

Expand Down Expand Up @@ -255,4 +256,57 @@ JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_CastStrings_fromInteger
}
CATCH_CAST_EXCEPTION(env, 0);
}

JNIEXPORT jlong JNICALL
Java_com_nvidia_spark_rapids_jni_CastStrings_toTimestamp(JNIEnv* env,
jclass,
jlong input_column,
jlong transitions_handle,
jlong tz_indices_col,
jint tz_default_index,
jboolean ansi_enabled)
{
JNI_NULL_CHECK(env, input_column, "input column is null", 0);
try {
cudf::jni::auto_set_device(env);

auto const& input_view =
cudf::strings_column_view(*reinterpret_cast<cudf::column_view const*>(input_column));
auto const transitions =
reinterpret_cast<cudf::table_view const*>(transitions_handle)->column(0);
const cudf::column_view* tz_indices_view =
reinterpret_cast<cudf::column_view const*>(tz_indices_col);
auto const tz_index = static_cast<cudf::size_type>(tz_default_index);
auto ret_cv = spark_rapids_jni::string_to_timestamp_with_tz(
input_view, transitions, *tz_indices_view, tz_index, ansi_enabled);
if (ret_cv) { return cudf::jni::release_as_jlong(ret_cv); }
}
CATCH_STD(env, 0);

// sucess is false, throw exception.
// Note: do not need to release ret_cv, because it's nullptr when success is
// false.
JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Parse failed on Ansi mode", 0);
revans2 marked this conversation as resolved.
Show resolved Hide resolved
}

JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_CastStrings_toTimestampWithoutTimeZone(
JNIEnv* env, jclass, jlong input_column, jboolean allow_time_zone, jboolean ansi_enabled)
{
JNI_NULL_CHECK(env, input_column, "input column is null", 0);
try {
cudf::jni::auto_set_device(env);
auto const& input_view =
cudf::strings_column_view(*reinterpret_cast<cudf::column_view const*>(input_column));

auto ret_cv =
spark_rapids_jni::string_to_timestamp_without_tz(input_view, allow_time_zone, ansi_enabled);
if (ret_cv) { return cudf::jni::release_as_jlong(ret_cv); }
}
CATCH_STD(env, 0);

// sucess is false, throw exception.
// Note: do not need to release ret_cv, because it's nullptr when success is
// false.
JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Parse failed on Ansi mode", 0);
revans2 marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading
Loading