diff --git a/ydb/library/yql/parser/pg_wrapper/ut/arrow_ut.cpp b/ydb/library/yql/parser/pg_wrapper/ut/arrow_ut.cpp index 28caad945d52..2ff79b30e739 100644 --- a/ydb/library/yql/parser/pg_wrapper/ut/arrow_ut.cpp +++ b/ydb/library/yql/parser/pg_wrapper/ut/arrow_ut.cpp @@ -10,6 +10,28 @@ extern "C" { #include "utils/fmgrprotos.h" } +namespace { + +void checkResult(const char ** expected, std::shared_ptr data) { + + NYql::NUdf::TStringBlockReader reader; + for (int i = 0; i < data->length; i++) { + auto item = reader.GetItem(*data, i); + if (!item) { + UNIT_ASSERT(expected[i] == nullptr); + } else { + const char* addr = item.AsStringRef().Data() + sizeof(void*); + UNIT_ASSERT(expected[i] != nullptr); + UNIT_ASSERT_VALUES_EQUAL( + TString(DatumGetCString(DirectFunctionCall1(numeric_out, (Datum)addr))), + expected[i] + ); + } + } +} + +} // namespace { + namespace NYql { Y_UNIT_TEST_SUITE(TArrowUtilsTests) { @@ -49,25 +71,14 @@ Y_UNIT_TEST(PgConvertNumericDouble) { auto result = PgConvertNumeric(array); const auto& data = result->data(); + + const char* expected[] = { "1.1", "31.37", nullptr, "-1.337", "0" }; - - NUdf::TStringBlockReader reader; - for (int i = 0; i < 5; i++) { - auto item = reader.GetItem(*data, i); - if (!item) { - UNIT_ASSERT(expected[i] == nullptr); - } else { - const char* addr = item.AsStringRef().Data() + sizeof(void*); - UNIT_ASSERT(expected[i] != nullptr); - UNIT_ASSERT_VALUES_EQUAL( - TString(DatumGetCString(DirectFunctionCall1(numeric_out, (Datum)addr))), - expected[i] - ); - } - } + + checkResult(expected, data); } Y_UNIT_TEST(PgConvertNumericInt) { @@ -89,21 +100,8 @@ Y_UNIT_TEST(PgConvertNumericInt) { const char* expected[] = { "11", "3137", nullptr, "-1337", "0" }; - - NUdf::TStringBlockReader reader; - for (int i = 0; i < 5; i++) { - auto item = reader.GetItem(*data, i); - if (!item) { - UNIT_ASSERT(expected[i] == nullptr); - } else { - const char* addr = item.AsStringRef().Data() + sizeof(void*); - UNIT_ASSERT(expected[i] != nullptr); - UNIT_ASSERT_VALUES_EQUAL( - TString(DatumGetCString(DirectFunctionCall1(numeric_out, (Datum)addr))), - expected[i] - ); - } - } + + checkResult(expected, data); } Y_UNIT_TEST(PgConvertDate32Date) { @@ -150,5 +148,4 @@ Y_UNIT_TEST(PgConvertDate32Date) { } // Y_UNIT_TEST_SUITE(TArrowUtilsTests) -} // namespace NYql - +} // namespace NYql \ No newline at end of file