aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/parser/pg_wrapper/ctors.cpp
blob: 90c62ea7c5c5c7691ef7f6c57b1c03a908e33c5f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "ctors.h"
#include <yql/essentials/parser/pg_catalog/catalog.h>

extern "C" {
#include "postgres.h"
#include "fmgr.h"
#include "varatt.h"
}

#undef Max
#include "utils.h"

namespace NYql {

namespace {

NUdf::TUnboxedValuePod ScalarValueToPodImpl(const bool value)   { return NUdf::TUnboxedValuePod(Datum(BoolGetDatum(value))); }
NUdf::TUnboxedValuePod ScalarValueToPodImpl(const i8 value)     { return NUdf::TUnboxedValuePod(Datum(Int8GetDatum(value))); }
NUdf::TUnboxedValuePod ScalarValueToPodImpl(const i16 value)    { return NUdf::TUnboxedValuePod(Datum(Int16GetDatum(value))); }
NUdf::TUnboxedValuePod ScalarValueToPodImpl(const i32 value)    { return NUdf::TUnboxedValuePod(Datum(Int32GetDatum(value))); }
NUdf::TUnboxedValuePod ScalarValueToPodImpl(const i64 value)    { return NUdf::TUnboxedValuePod(Datum(Int64GetDatum(value))); }
NUdf::TUnboxedValuePod ScalarValueToPodImpl(const ui8 value)    { return NUdf::TUnboxedValuePod(Datum(UInt8GetDatum(value))); }
NUdf::TUnboxedValuePod ScalarValueToPodImpl(const ui16 value)   { return NUdf::TUnboxedValuePod(Datum(UInt16GetDatum(value))); }
NUdf::TUnboxedValuePod ScalarValueToPodImpl(const ui32 value)   { return NUdf::TUnboxedValuePod(Datum(UInt32GetDatum(value))); }
NUdf::TUnboxedValuePod ScalarValueToPodImpl(const ui64 value)   { return NUdf::TUnboxedValuePod(Datum(UInt64GetDatum(value))); }
NUdf::TUnboxedValuePod ScalarValueToPodImpl(const float value)  { return NUdf::TUnboxedValuePod(Datum(Float4GetDatum(value))); }
NUdf::TUnboxedValuePod ScalarValueToPodImpl(const double value) { return NUdf::TUnboxedValuePod(Datum(Float8GetDatum(value))); }

NUdf::TUnboxedValuePod ScalarValueToPodImpl(const NUdf::TStringRef value) {
    return PointerDatumToPod(Datum(MakeVar(value)));
}

NUdf::TUnboxedValuePod ScalarValueToPodImpl(const std::string_view value) {
    return ScalarValueToPodImpl(NUdf::TStringRef(value));
}

}

template<typename ValueType>
NUdf::TUnboxedValuePod ScalarValueToPod(const ValueType value) {
    return ScalarValueToPodImpl(value);
}

template NUdf::TUnboxedValuePod ScalarValueToPod(const bool value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const i8 value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const i16 value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const i32 value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const i64 value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const ui8 value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const ui16 value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const ui32 value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const ui64 value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const float value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const double value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const std::string_view value);
template NUdf::TUnboxedValuePod ScalarValueToPod(const NUdf::TStringRef value);

}