aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/pg_dummy/pg_sql_dummy.cpp
blob: b7f5fd713ae813aad14555d480d7749c93f08b42 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
#include <yql/essentials/parser/pg_wrapper/interface/interface.h>

#include <yql/essentials/minikql/computation/mkql_computation_node_pack_impl.h>
#include <yql/essentials/minikql/mkql_buffer.h>

namespace NSQLTranslationPG {

NYql::TAstParseResult PGToYql(const TString& query, const NSQLTranslation::TTranslationSettings& settings, NYql::TStmtParseInfo* stmtParseInfo) {
    Y_UNUSED(query);
    Y_UNUSED(settings);
    Y_UNUSED(stmtParseInfo);
    NYql::TAstParseResult result;
    result.Issues.AddIssue(NYql::TIssue("PostgreSQL parser is not available"));
    return result;
}

TVector<NYql::TAstParseResult> PGToYqlStatements(const TString& query, const NSQLTranslation::TTranslationSettings& settings, TVector<NYql::TStmtParseInfo>* stmtParseInfo) {
    Y_UNUSED(query);
    Y_UNUSED(settings);
    Y_UNUSED(stmtParseInfo);
    return {};
}

std::unique_ptr<NYql::NPg::IExtensionSqlParser> CreateExtensionSqlParser() {
    throw yexception() << "CreateExtensionSqlParser: PG types are not supported";
}

std::unique_ptr<NYql::NPg::ISystemFunctionsParser> CreateSystemFunctionsParser() {
    throw yexception() << "CreateSystemFunctionsParser: PG types are not supported";
}

std::unique_ptr<NYql::NPg::ISqlLanguageParser> CreateSqlLanguageParser() {
    throw yexception() << "CreateSqlLanguageParser: PG types are not supported";
}

} // NSQLTranslationPG

namespace NYql {
namespace NCommon {

TString PgValueToString(const NUdf::TUnboxedValuePod& value, ui32 pgTypeId) {
    Y_UNUSED(value);
    Y_UNUSED(pgTypeId);
    throw yexception() << "PgValueToString: PG types are not supported";
}

NUdf::TUnboxedValue PgValueFromString(const TStringBuf text, ui32 pgTypeId) {
    Y_UNUSED(text);
    Y_UNUSED(pgTypeId);
    throw yexception() << "PgValueFromString: PG types are not supported";
}

TString PgValueToNativeText(const NUdf::TUnboxedValuePod& value, ui32 pgTypeId) {
    Y_UNUSED(value);
    Y_UNUSED(pgTypeId);
    throw yexception() << "PgValueToNativeText: PG types are not supported";
}

NUdf::TUnboxedValue PgValueFromNativeText(const TStringBuf text, ui32 pgTypeId) {
    Y_UNUSED(text);
    Y_UNUSED(pgTypeId);
    throw yexception() << "PgValueFromNativeText: PG types are not supported";
}

TString PgValueToNativeBinary(const NUdf::TUnboxedValuePod& value, ui32 pgTypeId) {
    Y_UNUSED(value);
    Y_UNUSED(pgTypeId);
    throw yexception() << "PgValueToNativeBinary: PG types are not supported";
}

NUdf::TUnboxedValue PgValueFromNativeBinary(const TStringBuf binary, ui32 pgTypeId) {
    Y_UNUSED(binary);
    Y_UNUSED(pgTypeId);
    throw yexception() << "PgValueFromNativeBinary: PG types are not supported";
}

TString PgValueCoerce(const NUdf::TUnboxedValuePod& value, ui32 pgTypeId, i32 typMod, TMaybe<TString>* error) {
    Y_UNUSED(value);
    Y_UNUSED(pgTypeId);
    Y_UNUSED(typMod);
    Y_UNUSED(error);
    throw yexception() << "PgValueCoerce: PG types are not supported";
}

void WriteYsonValuePg(NResult::TYsonResultWriter& writer, const NUdf::TUnboxedValuePod& value, NKikimr::NMiniKQL::TPgType* type,
    const TVector<ui32>* structPositions) {
    Y_UNUSED(writer);
    Y_UNUSED(value);
    Y_UNUSED(type);
    Y_UNUSED(structPositions);
    throw yexception() << "WriteYsonValuePg: PG types are not supported";
}

void WriteYsonValueInTableFormatPg(TOutputBuf& buf, NKikimr::NMiniKQL::TPgType* type, const NKikimr::NUdf::TUnboxedValuePod& value, bool topLevel) {
    Y_UNUSED(buf);
    Y_UNUSED(type);
    Y_UNUSED(value);
    Y_UNUSED(topLevel);
    throw yexception() << "WriteYsonValueInTableFormatPg: PG types are not supported";
}

NUdf::TUnboxedValue ReadYsonValueInTableFormatPg(NKikimr::NMiniKQL::TPgType* type, char cmd, TInputBuf& buf) {
    Y_UNUSED(type);
    Y_UNUSED(cmd);
    Y_UNUSED(buf);
    throw yexception() << "ReadYsonValueInTableFormatPg: PG types are not supported";
}

NUdf::TUnboxedValue ReadYsonValuePg(NKikimr::NMiniKQL::TPgType* type, char cmd, TInputBuf& buf) {
    Y_UNUSED(type);
    Y_UNUSED(cmd);
    Y_UNUSED(buf);
    throw yexception() << "ReadYsonValuePg: PG types are not supported";
}

void SkipSkiffPg(NKikimr::NMiniKQL::TPgType* type, NCommon::TInputBuf& buf) {
    Y_UNUSED(type);
    Y_UNUSED(buf);
    throw yexception() << "SkipSkiffPg: PG types are not supported";
}

NKikimr::NUdf::TUnboxedValue ReadSkiffPg(NKikimr::NMiniKQL::TPgType* type, NCommon::TInputBuf& buf) {
    Y_UNUSED(type);
    Y_UNUSED(buf);
    throw yexception() << "ReadSkiffPg: PG types are not supported";
}

void WriteSkiffPg(NKikimr::NMiniKQL::TPgType* type, const NKikimr::NUdf::TUnboxedValuePod& value, NCommon::TOutputBuf& buf) {
    Y_UNUSED(type);
    Y_UNUSED(value);
    Y_UNUSED(buf);
    throw yexception() << "WriteSkiffPg: PG types are not supported";
}

extern "C" void ReadSkiffPgValue(NKikimr::NMiniKQL::TPgType* type, NKikimr::NUdf::TUnboxedValue& value, NCommon::TInputBuf& buf) {
    Y_UNUSED(type);
    Y_UNUSED(value);
    Y_UNUSED(buf);
    throw yexception() << "ReadSkiffPgValue: PG types are not supported";
}

extern "C" void WriteSkiffPgValue(NKikimr::NMiniKQL::TPgType* type, const NKikimr::NUdf::TUnboxedValuePod& value, NCommon::TOutputBuf& buf) {
    Y_UNUSED(type);
    Y_UNUSED(value);
    Y_UNUSED(buf);
    throw yexception() << "WriteSkiffPgValue: PG types are not supported";
}

} // namespace NCommon
} // NYql

namespace NKikimr {
namespace NMiniKQL {

void* PgInitializeMainContext() {
    return nullptr;
}

void PgDestroyMainContext(void* ctx) {
    Y_UNUSED(ctx);
}

void PgAcquireThreadContext(void* ctx) {
    Y_UNUSED(ctx);
}

void PgReleaseThreadContext(void* ctx) {
    Y_UNUSED(ctx);
}

void PgSetGUCSettings(void* ctx, const TGUCSettings::TPtr& GUCSettings) {
    Y_UNUSED(ctx);
    Y_UNUSED(GUCSettings);
}

std::unique_ptr<NYql::NPg::IExtensionLoader> CreateExtensionLoader() {
    throw yexception() << "PG types are not supported";
}

std::optional<std::string> PGGetGUCSetting(const std::string& key) {
    Y_UNUSED(key);
    throw yexception() << "PG types are not supported";
}

ui64 PgValueSize(const NUdf::TUnboxedValuePod& value, i32 typeLen) {
    Y_UNUSED(typeLen);
    Y_UNUSED(value);
    throw yexception() << "PG types are not supported";
}

ui64 PgValueSize(ui32 type, const NUdf::TUnboxedValuePod& value) {
    Y_UNUSED(type);
    Y_UNUSED(value);
    throw yexception() << "PG types are not supported";
}

ui64 PgValueSize(const TPgType* type, const NUdf::TUnboxedValuePod& value) {
    Y_UNUSED(type);
    Y_UNUSED(value);
    throw yexception() << "PG types are not supported";
}

void PGPackImpl(bool stable, const TPgType* type, const NUdf::TUnboxedValuePod& value, TBuffer& buf) {
   Y_UNUSED(stable);
   Y_UNUSED(type);
   Y_UNUSED(value);
   Y_UNUSED(buf);
   throw yexception() << "PG types are not supported";
}

void PGPackImpl(bool stable, const TPgType* type, const NUdf::TUnboxedValuePod& value, NKikimr::NMiniKQL::TPagedBuffer& buf) {
   Y_UNUSED(stable);
   Y_UNUSED(type);
   Y_UNUSED(value);
   Y_UNUSED(buf);
   throw yexception() << "PG types are not supported";
}

NUdf::TUnboxedValue PGUnpackImpl(const TPgType* type, TStringBuf& buf) {
   Y_UNUSED(type);
   Y_UNUSED(buf);
   throw yexception() << "PG types are not supported";
}

NUdf::TUnboxedValue PGUnpackImpl(const TPgType* type, NDetails::TChunkedInputBuffer& buf) {
   Y_UNUSED(type);
   Y_UNUSED(buf);
   throw yexception() << "PG types are not supported";
}

void EncodePresortPGValue(TPgType* type, const NUdf::TUnboxedValue& value, TVector<ui8>& output) {
    Y_UNUSED(type);
    Y_UNUSED(value);
    Y_UNUSED(output);
    throw yexception() << "PG types are not supported";
}

NUdf::TUnboxedValue DecodePresortPGValue(TPgType* type, TStringBuf& input, TVector<ui8>& buffer) {
    Y_UNUSED(type);
    Y_UNUSED(input);
    Y_UNUSED(buffer);
    throw yexception() << "PG types are not supported";
}

void* PgInitializeContext(const std::string_view& contextType) {
   Y_UNUSED(contextType);
   return nullptr;
}

void PgDestroyContext(const std::string_view& contextType, void* ctx) {
   Y_UNUSED(contextType);
   Y_UNUSED(ctx);
}

NUdf::IHash::TPtr MakePgHash(const NMiniKQL::TPgType* type) {
    Y_UNUSED(type);
    throw yexception() << "PG types are not supported";
}

NUdf::ICompare::TPtr MakePgCompare(const NMiniKQL::TPgType* type) {
    Y_UNUSED(type);
    throw yexception() << "PG types are not supported";
}

NUdf::IEquate::TPtr MakePgEquate(const NMiniKQL::TPgType* type) {
    Y_UNUSED(type);
    throw yexception() << "PG types are not supported";
}

NUdf::IBlockItemComparator::TPtr MakePgItemComparator(ui32 typeId) {
    Y_UNUSED(typeId);
    throw yexception() << "PG types are not supported";
}

NUdf::IBlockItemHasher::TPtr MakePgItemHasher(ui32 typeId) {
    Y_UNUSED(typeId);
    throw yexception() << "PG types are not supported";
}

void RegisterPgBlockAggs(THashMap<TString, std::unique_ptr<IBlockAggregatorFactory>>& registry) {
    Y_UNUSED(registry);
}

} // namespace NMiniKQL
} // namespace NKikimr

namespace NYql {

arrow::Datum MakePgScalar(NKikimr::NMiniKQL::TPgType* type, const NKikimr::NUdf::TUnboxedValuePod& value, arrow::MemoryPool& pool) {
    Y_UNUSED(type);
    Y_UNUSED(value);
    Y_UNUSED(pool);
    return arrow::Datum();
}

arrow::Datum MakePgScalar(NKikimr::NMiniKQL::TPgType* type, const NUdf::TBlockItem& value, arrow::MemoryPool& pool) {
    Y_UNUSED(type);
    Y_UNUSED(value);
    Y_UNUSED(pool);
    return arrow::Datum();
}

TColumnConverter BuildPgColumnConverter(const std::shared_ptr<arrow::DataType>& originalType, NKikimr::NMiniKQL::TPgType* targetType) {
    Y_UNUSED(originalType);
    Y_UNUSED(targetType);
    return {};
}

ui32 ConvertToPgType(NKikimr::NUdf::EDataSlot slot) {
    Y_UNUSED(slot);
    throw yexception() << "PG types are not supported";
}

TMaybe<NKikimr::NUdf::EDataSlot> ConvertFromPgType(ui32 typeId) {
    Y_UNUSED(typeId);
    return Nothing();
}

bool ParsePgIntervalModifier(const TString& str, i32& ret) {
    Y_UNUSED(str);
    Y_UNUSED(ret);
    return false;
}

class TPgDummyBuilder : public NUdf::IPgBuilder {
public:
    NUdf::TUnboxedValue ValueFromText(ui32 typeId, const NUdf::TStringRef& value, NUdf::TStringValue& error) const override {
        Y_UNUSED(typeId);
        Y_UNUSED(value);
        error = NUdf::TStringValue(TStringBuf("TPgDummyBuilder::ValueFromText does nothing"));
        return NUdf::TUnboxedValue();
    }

    NUdf::TUnboxedValue ValueFromBinary(ui32 typeId, const NUdf::TStringRef& value, NUdf::TStringValue& error) const override {
        Y_UNUSED(typeId);
        Y_UNUSED(value);
        error = NUdf::TStringValue(TStringBuf("TPgDummyBuilder::ValueFromBinary does nothing"));
        return NUdf::TUnboxedValue();
    }

    NUdf::TUnboxedValue ConvertFromPg(NUdf::TUnboxedValue source, ui32 sourceTypeId, const NUdf::TType* targetType) const override {
        Y_UNUSED(source);
        Y_UNUSED(sourceTypeId);
        Y_UNUSED(targetType);
        ythrow yexception() << "TPgDummyBuilder::ConvertFromPg does nothing";
    }

    NUdf::TUnboxedValue ConvertToPg(NUdf::TUnboxedValue source, const NUdf::TType* sourceType, ui32 targetTypeId) const override {
        Y_UNUSED(source);
        Y_UNUSED(sourceType);
        Y_UNUSED(targetTypeId);
        ythrow yexception() << "TPgDummyBuilder::ConvertToPg does nothing";
    }

    NUdf::TUnboxedValue NewString(i32 typeLen, ui32 targetTypeId, NUdf::TStringRef data) const override {
        Y_UNUSED(typeLen);
        Y_UNUSED(targetTypeId);
        Y_UNUSED(data);
        ythrow yexception() << "TPgDummyBuilder::NewString does nothing";
    }

    NUdf::TStringRef AsCStringBuffer(const NUdf::TUnboxedValue& value) const override {
        Y_UNUSED(value);
        ythrow yexception() << "TPgDummyBuilder::AsCStringBuffer does nothing";
    }

    NUdf::TStringRef AsTextBuffer(const NUdf::TUnboxedValue& value) const override {
        Y_UNUSED(value);
        ythrow yexception() << "TPgDummyBuilder::AsTextBuffer does nothing";
    }

    NUdf::TUnboxedValue MakeCString(const char* value) const override {
        Y_UNUSED(value);
        ythrow yexception() << "TPgDummyBuilder::MakeCString does nothing";
    }

    NUdf::TUnboxedValue MakeText(const char* value) const override {
        Y_UNUSED(value);
        ythrow yexception() << "TPgDummyBuilder::MakeText does nothing";
    }

    NUdf::TStringRef AsFixedStringBuffer(const NUdf::TUnboxedValue& value, ui32 length) const override {
        Y_UNUSED(value);
        Y_UNUSED(length);
        ythrow yexception() << "TPgDummyBuilder::AsFixedStringBuffer does nothing";
    }
};

std::unique_ptr<NUdf::IPgBuilder> CreatePgBuilder() {
    return std::make_unique<TPgDummyBuilder>();
}

bool HasPgKernel(ui32 procOid) {
    Y_UNUSED(procOid);
    return false;
}

std::function<NKikimr::NMiniKQL::IComputationNode* (NKikimr::NMiniKQL::TCallable&,
    const NKikimr::NMiniKQL::TComputationNodeFactoryContext&)> GetPgFactory()
{
    return [] (
        NKikimr::NMiniKQL::TCallable& callable,
        const NKikimr::NMiniKQL::TComputationNodeFactoryContext& ctx
    ) -> NKikimr::NMiniKQL::IComputationNode* {
        Y_UNUSED(callable);
        Y_UNUSED(ctx);
        return nullptr;
    };
}

IOptimizer* MakePgOptimizerInternal(const IOptimizer::TInput& input, const std::function<void(const TString&)>& log)
{
    Y_UNUSED(input);
    Y_UNUSED(log);
    ythrow yexception() << "PgJoinSearch does nothing";
}

IOptimizerNew* MakePgOptimizerNew(IProviderContext& pctx, TExprContext& ctx, const std::function<void(const TString&)>& log)
{
    Y_UNUSED(pctx);
    Y_UNUSED(ctx);
    Y_UNUSED(log);
    ythrow yexception() << "PgJoinSearch does nothing";
}

} // NYql

namespace NKikimr::NPg {

ui32 PgTypeIdFromTypeDesc(const ITypeDesc* typeDesc) {
    Y_UNUSED(typeDesc);
    return 0;
}

const ITypeDesc* TypeDescFromPgTypeId(ui32 pgTypeId) {
    Y_UNUSED(pgTypeId);
    return {};
}

TString PgTypeNameFromTypeDesc(const ITypeDesc* typeDesc, const TString& typeMod) {
    Y_UNUSED(typeDesc);
    Y_UNUSED(typeMod);
    return "";
}

const ITypeDesc* TypeDescFromPgTypeName(const TStringBuf name) {
    Y_UNUSED(name);
    return {};
}

TString TypeModFromPgTypeName(const TStringBuf name) {
    Y_UNUSED(name);
    return {};
}

bool TypeDescIsComparable(const ITypeDesc* typeDesc) {
    Y_UNUSED(typeDesc);
    throw yexception() << "PG types are not supported";
}

i32 TypeDescGetTypeLen(const ITypeDesc* typeDesc) {
    Y_UNUSED(typeDesc);
    throw yexception() << "PG types are not supported";
}

ui32 TypeDescGetStoredSize(const ITypeDesc* typeDesc) {
    Y_UNUSED(typeDesc);
    throw yexception() << "PG types are not supported";
}

bool TypeDescNeedsCoercion(const ITypeDesc* typeDesc) {
    Y_UNUSED(typeDesc);
    throw yexception() << "PG types are not supported";
}

int PgNativeBinaryCompare(const char* dataL, size_t sizeL, const char* dataR, size_t sizeR, const ITypeDesc* typeDesc) {
    Y_UNUSED(dataL);
    Y_UNUSED(sizeL);
    Y_UNUSED(dataR);
    Y_UNUSED(sizeR);
    Y_UNUSED(typeDesc);
    throw yexception() << "PG types are not supported";
}

ui64 PgNativeBinaryHash(const char* data, size_t size, const ITypeDesc* typeDesc) {
    Y_UNUSED(data);
    Y_UNUSED(size);
    Y_UNUSED(typeDesc);
    throw yexception() << "PG types are not supported";
}

TTypeModResult BinaryTypeModFromTextTypeMod(const TString& str, const ITypeDesc* typeDesc) {
    Y_UNUSED(str);
    Y_UNUSED(typeDesc);
    throw yexception() << "PG types are not supported";
}

TMaybe<TString> PgNativeBinaryValidate(const TStringBuf binary, const ITypeDesc* typeDesc) {
    Y_UNUSED(binary);
    Y_UNUSED(typeDesc);
    throw yexception() << "PG types are not supported";
}

TCoerceResult PgNativeBinaryCoerce(const TStringBuf binary, const ITypeDesc* typeDesc, i32 typmod) {
    Y_UNUSED(binary);
    Y_UNUSED(typeDesc);
    Y_UNUSED(typmod);
    throw yexception() << "PG types are not supported";
}

TConvertResult PgNativeBinaryFromNativeText(const TString& str, const ITypeDesc* typeDesc) {
    Y_UNUSED(str);
    Y_UNUSED(typeDesc);
    throw yexception() << "PG types are not supported";
}

TConvertResult PgNativeBinaryFromNativeText(const TString& str, ui32 pgTypeId) {
    Y_UNUSED(str);
    Y_UNUSED(pgTypeId);
    throw yexception() << "PG types are not supported";
}

TConvertResult PgNativeTextFromNativeBinary(const TStringBuf binary, const ITypeDesc* typeDesc) {
    Y_UNUSED(binary);
    Y_UNUSED(typeDesc);
    throw yexception() << "PG types are not supported";
}

TConvertResult PgNativeTextFromNativeBinary(const TStringBuf binary, ui32 pgTypeId) {
    Y_UNUSED(binary);
    Y_UNUSED(pgTypeId);
    throw yexception() << "PG types are not supported";
}

TString GetPostgresServerVersionNum() {
    return "-1";
}
TString GetPostgresServerVersionStr() {
    return "pg_sql_dummy";
}

} // namespace NKikimr::NPg

namespace NYql {

ui64 HexEncode(const char *src, size_t len, char *dst) {
    Y_UNUSED(src);
    Y_UNUSED(len);
    Y_UNUSED(dst);

    throw yexception() << "HexEncode in pg_dummy does nothing";
}

} // NYql