Skip to content

Commit 55fc639

Browse files
authored
Make error for impossible TzDate casts more friendly (again) (#8595)
1 parent 6191791 commit 55fc639

File tree

2 files changed

+11
-5
lines changed
  • ydb/library/yql
    • tests/sql/yt_native_file/part18/canondata/test.test_datetime-date_tz_impossible_cast--Results_
    • udfs/common/datetime2

2 files changed

+11
-5
lines changed

ydb/library/yql/tests/sql/yt_native_file/part18/canondata/test.test_datetime-date_tz_impossible_cast--Results_/extracted

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<tmp_path>/program.sql:<main>:1:1: Fatal: Execution of node: Result
44
SELECT
55
^
6-
<tmp_path>/program.sql:<main>:2:5: Fatal: (yexception) ydb/library/yql/minikql/datetime/datetime.h:xxx: Error in MakeDatetime
7-
[MakeTzDate]
6+
<tmp_path>/program.sql:<main>:2:5: Fatal: Timestamp 1970-01-01T23:59:59.000000,Europe/Moscow cannot be casted to TzDate
87
CAST(AddTimezone(
98
^

ydb/library/yql/udfs/common/datetime2/datetime_udf.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,9 +848,16 @@ TValue DoAddYears(const TValue& date, i64 years, const NUdf::IDateBuilder& build
848848
BEGIN_SIMPLE_STRICT_ARROW_UDF(TMakeTzDate, TTzDate(TAutoMap<TResource<TMResourceName>>)) {
849849
auto& builder = valueBuilder->GetDateBuilder();
850850
auto& storage = Reference(args[0]);
851-
TUnboxedValuePod result(storage.ToDate(builder, true));
852-
result.SetTimezoneId(storage.TimezoneId);
853-
return result;
851+
try {
852+
TUnboxedValuePod result(storage.ToDate(builder, true));
853+
result.SetTimezoneId(storage.TimezoneId);
854+
return result;
855+
} catch (const std::exception& e) {
856+
UdfTerminate((TStringBuilder() << Pos_ << "Timestamp "
857+
<< storage.ToString()
858+
<< " cannot be casted to TzDate"
859+
).data());
860+
}
854861
}
855862
END_SIMPLE_ARROW_UDF(TMakeTzDate, TMakeDateKernelExec<TTzDate>::Do);
856863

0 commit comments

Comments
 (0)