aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/parser/pg_wrapper/interface/codec.h
blob: c2aa3c4af0dfe0576869994772a86de3d63e6242 (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
#pragma once

#include <yql/essentials/public/udf/udf_value.h>

#include <util/generic/strbuf.h>
#include <util/generic/string.h>

namespace NKikimr {
namespace NMiniKQL {

class TPgType;

} // NMiniKQL
} // NKikimr

namespace NYql {
namespace NResult {
class TYsonResultWriter;
}

namespace NCommon {

class TInputBuf;
class TOutputBuf;

TString PgValueToString(const NUdf::TUnboxedValuePod& value, ui32 pgTypeId);
NUdf::TUnboxedValue PgValueFromString(const TStringBuf text, ui32 pgTypeId);

TString PgValueToNativeText(const NUdf::TUnboxedValuePod& value, ui32 pgTypeId);
NUdf::TUnboxedValue PgValueFromNativeText(const TStringBuf text, ui32 pgTypeId);

TString PgValueToNativeBinary(const NUdf::TUnboxedValuePod& value, ui32 pgTypeId);
NUdf::TUnboxedValue PgValueFromNativeBinary(const TStringBuf binary, ui32 pgTypeId);

TString PgValueCoerce(const NUdf::TUnboxedValuePod& value, ui32 pgTypeId, i32 typMod, TMaybe<TString>* error);

void WriteYsonValuePg(NResult::TYsonResultWriter& writer, const NUdf::TUnboxedValuePod& value, NKikimr::NMiniKQL::TPgType* type,
    const TVector<ui32>* structPositions);

void WriteYsonValueInTableFormatPg(TOutputBuf& buf, NKikimr::NMiniKQL::TPgType* type, const NKikimr::NUdf::TUnboxedValuePod& value, bool topLevel);

NUdf::TUnboxedValue ReadYsonValueInTableFormatPg(NKikimr::NMiniKQL::TPgType* type, char cmd, TInputBuf& buf);
NUdf::TUnboxedValue ReadYsonValuePg(NKikimr::NMiniKQL::TPgType* type, char cmd, TInputBuf& buf);

void SkipSkiffPg(NKikimr::NMiniKQL::TPgType* type, TInputBuf& buf);

NKikimr::NUdf::TUnboxedValue ReadSkiffPg(NKikimr::NMiniKQL::TPgType* type, TInputBuf& buf);
void WriteSkiffPg(NKikimr::NMiniKQL::TPgType* type, const NKikimr::NUdf::TUnboxedValuePod& value, TOutputBuf& buf);

extern "C" void ReadSkiffPgValue(NKikimr::NMiniKQL::TPgType* type, NKikimr::NUdf::TUnboxedValue& value, TInputBuf& buf);
extern "C" void WriteSkiffPgValue(NKikimr::NMiniKQL::TPgType* type, const NKikimr::NUdf::TUnboxedValuePod& value, TOutputBuf& buf);

} // namespace NCommon
} // namespace NYql