ctors.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "ctors.h"
  2. #include <yql/essentials/parser/pg_catalog/catalog.h>
  3. extern "C" {
  4. #include "postgres.h"
  5. #include "fmgr.h"
  6. #include "varatt.h"
  7. }
  8. #undef Max
  9. #include "utils.h"
  10. namespace NYql {
  11. namespace {
  12. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const bool value) { return NUdf::TUnboxedValuePod(Datum(BoolGetDatum(value))); }
  13. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const i8 value) { return NUdf::TUnboxedValuePod(Datum(Int8GetDatum(value))); }
  14. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const i16 value) { return NUdf::TUnboxedValuePod(Datum(Int16GetDatum(value))); }
  15. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const i32 value) { return NUdf::TUnboxedValuePod(Datum(Int32GetDatum(value))); }
  16. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const i64 value) { return NUdf::TUnboxedValuePod(Datum(Int64GetDatum(value))); }
  17. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const ui8 value) { return NUdf::TUnboxedValuePod(Datum(UInt8GetDatum(value))); }
  18. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const ui16 value) { return NUdf::TUnboxedValuePod(Datum(UInt16GetDatum(value))); }
  19. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const ui32 value) { return NUdf::TUnboxedValuePod(Datum(UInt32GetDatum(value))); }
  20. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const ui64 value) { return NUdf::TUnboxedValuePod(Datum(UInt64GetDatum(value))); }
  21. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const float value) { return NUdf::TUnboxedValuePod(Datum(Float4GetDatum(value))); }
  22. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const double value) { return NUdf::TUnboxedValuePod(Datum(Float8GetDatum(value))); }
  23. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const NUdf::TStringRef value) {
  24. return PointerDatumToPod(Datum(MakeVar(value)));
  25. }
  26. NUdf::TUnboxedValuePod ScalarValueToPodImpl(const std::string_view value) {
  27. return ScalarValueToPodImpl(NUdf::TStringRef(value));
  28. }
  29. }
  30. template<typename ValueType>
  31. NUdf::TUnboxedValuePod ScalarValueToPod(const ValueType value) {
  32. return ScalarValueToPodImpl(value);
  33. }
  34. template NUdf::TUnboxedValuePod ScalarValueToPod(const bool value);
  35. template NUdf::TUnboxedValuePod ScalarValueToPod(const i8 value);
  36. template NUdf::TUnboxedValuePod ScalarValueToPod(const i16 value);
  37. template NUdf::TUnboxedValuePod ScalarValueToPod(const i32 value);
  38. template NUdf::TUnboxedValuePod ScalarValueToPod(const i64 value);
  39. template NUdf::TUnboxedValuePod ScalarValueToPod(const ui8 value);
  40. template NUdf::TUnboxedValuePod ScalarValueToPod(const ui16 value);
  41. template NUdf::TUnboxedValuePod ScalarValueToPod(const ui32 value);
  42. template NUdf::TUnboxedValuePod ScalarValueToPod(const ui64 value);
  43. template NUdf::TUnboxedValuePod ScalarValueToPod(const float value);
  44. template NUdf::TUnboxedValuePod ScalarValueToPod(const double value);
  45. template NUdf::TUnboxedValuePod ScalarValueToPod(const std::string_view value);
  46. template NUdf::TUnboxedValuePod ScalarValueToPod(const NUdf::TStringRef value);
  47. }