diff options
| author | panikku <[email protected]> | 2025-06-20 11:33:52 +0300 |
|---|---|---|
| committer | panikku <[email protected]> | 2025-06-20 12:04:50 +0300 |
| commit | d4b975945b54f49d3a106ebc5a392a49944f2f88 (patch) | |
| tree | 93d52b7bd8f364f8c0a0e228df2939ddfc49d746 | |
| parent | 815bb53e8a110e23218e610caabd6a3e15fa3ca5 (diff) | |
YQL-19934: Fix Unicode / Error location display
Fix Unicode/ error line
commit_hash:aa5f17b1dd12a3b69869458c6f5aa92bb8514257
11 files changed, 53 insertions, 51 deletions
diff --git a/yql/essentials/public/udf/arrow/udf_arrow_helpers.h b/yql/essentials/public/udf/arrow/udf_arrow_helpers.h index cd4cd4b06bf..add584513f9 100644 --- a/yql/essentials/public/udf/arrow/udf_arrow_helpers.h +++ b/yql/essentials/public/udf/arrow/udf_arrow_helpers.h @@ -214,11 +214,10 @@ public: return valueBuilder->ImportArrowBlock(a.data(), a.size(), false, *ReturnArrowTypeHandle_); } - } catch (const std::exception&) { + } catch (const std::exception& ex) { TStringBuilder sb; - sb << Pos_ << " "; - sb << CurrentExceptionMessage(); - sb << Endl << "[" << Name_ << "]"; + APPEND_SOURCE_LOCATION(sb, valueBuilder, Pos_) + sb << ex.what(); UdfTerminate(sb.c_str()); } } diff --git a/yql/essentials/public/udf/udf_helpers.h b/yql/essentials/public/udf/udf_helpers.h index b6fceb086d9..ad9db2db982 100644 --- a/yql/essentials/public/udf/udf_helpers.h +++ b/yql/essentials/public/udf/udf_helpers.h @@ -43,6 +43,12 @@ namespace NUdf { } } +#if UDF_ABI_COMPATIBILITY_VERSION_CURRENT >= UDF_ABI_COMPATIBILITY_VERSION(2, 17) + #define APPEND_SOURCE_LOCATION(sb, valueBuilder, Pos_) sb << valueBuilder->WithCalleePosition(Pos_) << " "; +#else + #define APPEND_SOURCE_LOCATION(sb, valueBuilder, Pos_) sb << Pos_ << " "; +#endif + #define UDF_IMPL_EX(udfName, typeBody, members, init, irResourceId, irFunctionName, blockType, create_impl) \ class udfName: public ::NYql::NUdf::TBoxedValue { \ public: \ @@ -63,16 +69,15 @@ namespace NUdf { const ::NYql::NUdf::IValueBuilder* valueBuilder, \ const ::NYql::NUdf::TUnboxedValuePod* args) const override { \ try { \ - return RunImpl(valueBuilder, args); \ - } catch (const std::exception&) { \ - TStringBuilder sb; \ - sb << Pos_ << " "; \ - sb << CurrentExceptionMessage(); \ - sb << Endl << "[" << TStringBuf(Name()) << "]" ; \ - UdfTerminate(sb.c_str()); \ - } \ - } \ - static bool DeclareSignature( \ + return RunImpl(valueBuilder, args); \ + } catch (const std::exception& ex) { \ + TStringBuilder sb; \ + APPEND_SOURCE_LOCATION(sb, valueBuilder, Pos_) \ + sb << ex.what(); \ + UdfTerminate(sb.c_str()); \ + } \ + } \ + static bool DeclareSignature( \ const ::NYql::NUdf::TStringRef& name, \ ::NYql::NUdf::TType* userType, \ ::NYql::NUdf::IFunctionTypeInfoBuilder& builder, \ @@ -132,16 +137,15 @@ namespace NUdf { ::NYql::NUdf::TUnboxedValue Run( \ const ::NYql::NUdf::IValueBuilder* valueBuilder, \ const ::NYql::NUdf::TUnboxedValuePod* args) const override { \ - try { \ - return RunImpl(valueBuilder, args); \ - } catch (const std::exception&) { \ - TStringBuilder sb; \ - sb << Pos_ << " "; \ - sb << CurrentExceptionMessage(); \ - sb << Endl << "[" << TStringBuf(Name()) << "]" ; \ - UdfTerminate(sb.c_str()); \ - } \ - } \ + try { \ + return RunImpl(valueBuilder, args); \ + } catch (const std::exception& ex) { \ + TStringBuilder sb; \ + APPEND_SOURCE_LOCATION(sb, valueBuilder, Pos_) \ + sb << ex.what(); \ + UdfTerminate(sb.c_str()); \ + } \ + } \ \ private: \ ::NYql::NUdf::TUnboxedValue RunConfig; \ diff --git a/yql/essentials/udfs/common/unicode_base/lib/unicode_base_udf.h b/yql/essentials/udfs/common/unicode_base/lib/unicode_base_udf.h index d27abcb9f65..850990d7ba9 100644 --- a/yql/essentials/udfs/common/unicode_base/lib/unicode_base_udf.h +++ b/yql/essentials/udfs/common/unicode_base/lib/unicode_base_udf.h @@ -101,7 +101,6 @@ namespace { args[2] ? TMaybe<ui64>(args[2].Get<ui64>()) : Nothing()); return ProcessResult(builder, std::move(executeResult), args); } - private: static TUnboxedValue ProcessResult(const IValueBuilder* builder, const TString& newString, const TUnboxedValuePod*) { return builder->NewString(newString); @@ -359,7 +358,7 @@ namespace { try { unicodeSet.Parse(customCategory); } catch (...) { - UdfTerminate((TStringBuilder() << "Failed to parse unicode set: " << CurrentExceptionMessage()).c_str()); + throw yexception() << "Failed to parse unicode set: " << CurrentExceptionMessage(); } wchar32 rune; const unsigned char* cur = reinterpret_cast<const unsigned char*>(input.begin()); @@ -494,7 +493,7 @@ namespace { if constexpr (strict) { return Nothing(); } else { - UdfTerminate(message); + throw yexception() << message; } }; diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F0_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F0_/extracted index f8d4992f9e1..5cca7576df3 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F0_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F0_/extracted @@ -3,6 +3,6 @@ <tmp_path>/program.sql:<main>:10:1: Error: Execution of node: YtMap! SELECT ^ - <tmp_path>/program.sql:<main>:10:1: Error: Input string is not a number - SELECT - ^
\ No newline at end of file + <tmp_path>/program.sql:<main>:14:14: Error: Input string is not a number + Unicode::ToUint64(value), + ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F1_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F1_/extracted index bbdeae1af46..d2cca2308ac 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F1_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F1_/extracted @@ -3,6 +3,6 @@ <tmp_path>/program.sql:<main>:10:1: Error: Execution of node: YtMap! SELECT ^ - <tmp_path>/program.sql:<main>:10:1: Error: Input string contains junk after the number - SELECT - ^
\ No newline at end of file + <tmp_path>/program.sql:<main>:14:14: Error: Input string contains junk after the number + Unicode::ToUint64(value), + ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F2_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F2_/extracted index e15ed0de7a4..408e90e57e9 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F2_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F2_/extracted @@ -3,6 +3,6 @@ <tmp_path>/program.sql:<main>:10:1: Error: Execution of node: YtMap! SELECT ^ - <tmp_path>/program.sql:<main>:10:1: Error: Converted value falls out of Uint64 range - SELECT - ^
\ No newline at end of file + <tmp_path>/program.sql:<main>:14:14: Error: Converted value falls out of Uint64 range + Unicode::ToUint64(value), + ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F3_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F3_/extracted index aff4bb4c226..fea68335566 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F3_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_BlockToUint64F3_/extracted @@ -3,6 +3,6 @@ <tmp_path>/program.sql:<main>:10:1: Error: Execution of node: YtMap! SELECT ^ - <tmp_path>/program.sql:<main>:10:1: Error: Incorrect base - SELECT - ^
\ No newline at end of file + <tmp_path>/program.sql:<main>:14:14: Error: Incorrect base + Unicode::ToUint64(value, 1), + ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F0_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F0_/extracted index 6c16e6c2e39..891b90432ef 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F0_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F0_/extracted @@ -3,6 +3,6 @@ <tmp_path>/program.sql:<main>:4:1: Error: Execution of node: YtMap! SELECT ^ - <tmp_path>/program.sql:<main>:4:1: Error: Input string is not a number - SELECT - ^
\ No newline at end of file + <tmp_path>/program.sql:<main>:8:14: Error: Input string is not a number + Unicode::ToUint64(value), + ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F1_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F1_/extracted index 4288cfcc4c7..a7efc21dfbf 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F1_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F1_/extracted @@ -3,6 +3,6 @@ <tmp_path>/program.sql:<main>:4:1: Error: Execution of node: YtMap! SELECT ^ - <tmp_path>/program.sql:<main>:4:1: Error: Input string contains junk after the number - SELECT - ^
\ No newline at end of file + <tmp_path>/program.sql:<main>:8:14: Error: Input string contains junk after the number + Unicode::ToUint64(value), + ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F2_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F2_/extracted index 7ebb531e661..8c26d414cc9 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F2_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F2_/extracted @@ -3,6 +3,6 @@ <tmp_path>/program.sql:<main>:4:1: Error: Execution of node: YtMap! SELECT ^ - <tmp_path>/program.sql:<main>:4:1: Error: Converted value falls out of Uint64 range - SELECT - ^
\ No newline at end of file + <tmp_path>/program.sql:<main>:8:14: Error: Converted value falls out of Uint64 range + Unicode::ToUint64(value), + ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F3_/extracted b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F3_/extracted index 6ff53caa9a2..c4afb1596ec 100644 --- a/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F3_/extracted +++ b/yql/essentials/udfs/common/unicode_base/test/canondata/test.test_ToUint64F3_/extracted @@ -3,6 +3,6 @@ <tmp_path>/program.sql:<main>:4:1: Error: Execution of node: YtMap! SELECT ^ - <tmp_path>/program.sql:<main>:4:1: Error: Incorrect base - SELECT - ^
\ No newline at end of file + <tmp_path>/program.sql:<main>:8:14: Error: Incorrect base + Unicode::ToUint64(value, 1), + ^
\ No newline at end of file |
