#include "pg_include.h" #include #include #include namespace NYql { std::expected PgSign(TStringBuf value, ui32 typeId) { try { NKikimr::NMiniKQL::TOnlyThrowingBindTerminator bind; NKikimr::NMiniKQL::TScopedAlloc alloc(__LOCATION__); NKikimr::NMiniKQL::TPAllocScope scope; TPgConst pgConst(typeId, value); auto pgValue = pgConst.ExtractConst(); auto signFunc = TPgSign::Create(typeId); auto sign = signFunc->MakeCallState()->GetSign(pgValue); if (!sign) { return std::unexpected(TString("Value is NULL")); } if (*sign < 0) { return std::strong_ordering::less; } else if (*sign > 0) { return std::strong_ordering::greater; } else { return std::strong_ordering::equal; } } catch (const NYql::NPg::TProcNotFoundException& e) { return std::unexpected(TString(e.what())); } catch (const NYql::NPg::TOperatorNotFoundException& e) { return std::unexpected(TString(e.what())); } } } // namespace NYql