Skip to content

Commit 57335a0

Browse files
authored
Merge 710c933 into b16f3db
2 parents b16f3db + 710c933 commit 57335a0

File tree

134 files changed

+10784
-10672
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+10784
-10672
lines changed

ydb/library/yql/parser/pg_wrapper/arrow.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ extern "C" {
1919
namespace NYql {
2020

2121
extern "C" {
22+
Y_PRAGMA_DIAGNOSTIC_PUSH
23+
Y_PRAGMA("GCC diagnostic ignored \"-Wreturn-type-c-linkage\"")
2224
#include "pg_kernels_fwd.inc"
25+
Y_PRAGMA_DIAGNOSTIC_POP
2326
}
2427

2528
struct TExecs {
@@ -114,7 +117,7 @@ std::shared_ptr<arrow::Array> PgConvertString(const std::shared_ptr<arrow::Array
114117
for (size_t i = 0; i < length; ++i) {
115118
auto item = reader.GetItem(*data, i);
116119
if (!item) {
117-
builder.AppendNull();
120+
ARROW_OK(builder.AppendNull());
118121
continue;
119122
}
120123

ydb/library/yql/parser/pg_wrapper/arrow.h

+3
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ struct TDefaultArgsPolicy {
241241
static constexpr std::array<bool, 0> IsFixedArg = {};
242242
};
243243

244+
Y_PRAGMA_DIAGNOSTIC_PUSH
245+
Y_PRAGMA("GCC diagnostic ignored \"-Wreturn-type-c-linkage\"")
244246
extern "C" TPgKernelState& GetPGKernelState(arrow::compute::KernelContext* ctx);
247+
Y_PRAGMA_DIAGNOSTIC_POP
245248

246249
template <typename TFunc, bool IsStrict, bool IsFixedResult, typename TArgsPolicy = TDefaultArgsPolicy>
247250
struct TGenericExec {

ydb/library/yql/parser/pg_wrapper/arrow_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ std::shared_ptr<arrow::Array> PgConvertNumeric(const std::shared_ptr<arrow::Arra
2222
auto input = data->GetValues<T>(1);
2323
for (size_t i = 0; i < length; ++i) {
2424
if (value->IsNull(i)) {
25-
builder.AppendNull();
25+
ARROW_OK(builder.AppendNull());
2626
continue;
2727
}
2828
T item = input[i];

ydb/library/yql/parser/pg_wrapper/cflags.inc

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CFLAGS(
99
-Wno-duplicate-decl-specifier
1010
-Wno-unused-function
1111
-Wno-unused-variable
12+
-Wno-unused-but-set-variable
1213
-Wno-unused-private-field
1314
-Wno-register
1415
-Wno-unguarded-availability-new

ydb/library/yql/parser/pg_wrapper/comp_factory.cpp

+75-34
Original file line numberDiff line numberDiff line change
@@ -3500,9 +3500,9 @@ void PgDestroyContext(const std::string_view& contextType, void* ctx) {
35003500
}
35013501

35023502
template <bool PassByValue, bool IsArray>
3503-
class TPgHash : public NUdf::IHash, public NUdf::TBlockItemHasherBase<TPgHash<PassByValue, IsArray>, true> {
3503+
class TPgHashBase {
35043504
public:
3505-
TPgHash(const NYql::NPg::TTypeDesc& typeDesc)
3505+
TPgHashBase(const NYql::NPg::TTypeDesc& typeDesc)
35063506
: TypeDesc(typeDesc)
35073507
{
35083508
auto hashProcId = TypeDesc.HashProcId;
@@ -3521,10 +3521,25 @@ class TPgHash : public NUdf::IHash, public NUdf::TBlockItemHasherBase<TPgHash<Pa
35213521
Y_ENSURE(FInfoHash.fn_nargs == 1);
35223522
}
35233523

3524+
protected:
3525+
const NYql::NPg::TTypeDesc TypeDesc;
3526+
3527+
FmgrInfo FInfoHash;
3528+
};
3529+
3530+
template <bool PassByValue, bool IsArray>
3531+
class TPgHash : public TPgHashBase<PassByValue, IsArray>, public NUdf::IHash {
3532+
public:
3533+
using TBase = TPgHashBase<PassByValue, IsArray>;
3534+
3535+
TPgHash(const NYql::NPg::TTypeDesc& typeDesc)
3536+
: TBase(typeDesc)
3537+
{}
3538+
35243539
ui64 Hash(NUdf::TUnboxedValuePod lhs) const override {
35253540
LOCAL_FCINFO(callInfo, 1);
35263541
Zero(*callInfo);
3527-
callInfo->flinfo = const_cast<FmgrInfo*>(&FInfoHash); // don't copy becase of IHash isn't threadsafe
3542+
callInfo->flinfo = const_cast<FmgrInfo*>(&this->FInfoHash); // don't copy becase of IHash isn't threadsafe
35283543
callInfo->nargs = 1;
35293544
callInfo->fncollation = DEFAULT_COLLATION_OID;
35303545
callInfo->isnull = false;
@@ -3536,30 +3551,36 @@ class TPgHash : public NUdf::IHash, public NUdf::TBlockItemHasherBase<TPgHash<Pa
35363551
ScalarDatumFromPod(lhs) :
35373552
PointerDatumFromPod(lhs), false };
35383553

3539-
auto x = FInfoHash.fn_addr(callInfo);
3554+
auto x = this->FInfoHash.fn_addr(callInfo);
35403555
Y_ENSURE(!callInfo->isnull);
35413556
return DatumGetUInt32(x);
35423557
}
3558+
};
3559+
3560+
template <bool PassByValue, bool IsArray>
3561+
class TPgHashItem : public TPgHashBase<PassByValue, IsArray>, public NUdf::TBlockItemHasherBase<TPgHashItem<PassByValue, IsArray>, true> {
3562+
public:
3563+
using TBase = TPgHashBase<PassByValue, IsArray>;
3564+
3565+
TPgHashItem(const NYql::NPg::TTypeDesc& typeDesc)
3566+
: TBase(typeDesc)
3567+
{}
35433568

35443569
ui64 DoHash(NUdf::TBlockItem value) const {
35453570
LOCAL_FCINFO(callInfo, 1);
35463571
Zero(*callInfo);
3547-
callInfo->flinfo = const_cast<FmgrInfo*>(&FInfoHash); // don't copy becase of IHash isn't threadsafe
3572+
callInfo->flinfo = const_cast<FmgrInfo*>(&this->FInfoHash); // don't copy becase of IHash isn't threadsafe
35483573
callInfo->nargs = 1;
35493574
callInfo->fncollation = DEFAULT_COLLATION_OID;
35503575
callInfo->isnull = false;
35513576
callInfo->args[0] = { PassByValue ?
35523577
ScalarDatumFromItem(value) :
35533578
PointerDatumFromItem(value), false };
35543579

3555-
auto x = FInfoHash.fn_addr(callInfo);
3580+
auto x = this->FInfoHash.fn_addr(callInfo);
35563581
Y_ENSURE(!callInfo->isnull);
35573582
return DatumGetUInt32(x);
35583583
}
3559-
private:
3560-
const NYql::NPg::TTypeDesc TypeDesc;
3561-
3562-
FmgrInfo FInfoHash;
35633584
};
35643585

35653586
NUdf::IHash::TPtr MakePgHash(const NMiniKQL::TPgType* type) {
@@ -3576,18 +3597,18 @@ NUdf::IHash::TPtr MakePgHash(const NMiniKQL::TPgType* type) {
35763597
NUdf::IBlockItemHasher::TPtr MakePgItemHasher(ui32 typeId) {
35773598
const auto& typeDesc = NYql::NPg::LookupType(typeId);
35783599
if (typeDesc.PassByValue) {
3579-
return new TPgHash<true, false>(typeDesc);
3600+
return new TPgHashItem<true, false>(typeDesc);
35803601
} else if (typeDesc.TypeId == typeDesc.ArrayTypeId) {
3581-
return new TPgHash<false, true>(typeDesc);
3602+
return new TPgHashItem<false, true>(typeDesc);
35823603
} else {
3583-
return new TPgHash<false, false>(typeDesc);
3604+
return new TPgHashItem<false, false>(typeDesc);
35843605
}
35853606
}
35863607

35873608
template <bool PassByValue, bool IsArray>
3588-
class TPgCompare : public NUdf::ICompare, public NUdf::TBlockItemComparatorBase<TPgCompare<PassByValue, IsArray>, true> {
3609+
class TPgCompareBase {
35893610
public:
3590-
TPgCompare(const NYql::NPg::TTypeDesc& typeDesc)
3611+
TPgCompareBase(const NYql::NPg::TTypeDesc& typeDesc)
35913612
: TypeDesc(typeDesc)
35923613
{
35933614
Zero(FInfoLess);
@@ -3624,14 +3645,29 @@ class TPgCompare : public NUdf::ICompare, public NUdf::TBlockItemComparatorBase<
36243645
Y_ENSURE(FInfoCompare.fn_nargs == 2);
36253646
}
36263647

3648+
protected:
3649+
const NYql::NPg::TTypeDesc TypeDesc;
3650+
3651+
FmgrInfo FInfoLess, FInfoCompare, FInfoEquals;
3652+
};
3653+
3654+
template <bool PassByValue, bool IsArray>
3655+
class TPgCompare : public TPgCompareBase<PassByValue, IsArray>, public NUdf::ICompare {
3656+
public:
3657+
using TBase = TPgCompareBase<PassByValue, IsArray>;
3658+
3659+
TPgCompare(const NYql::NPg::TTypeDesc& typeDesc)
3660+
: TBase(typeDesc)
3661+
{}
3662+
36273663
bool Less(NUdf::TUnboxedValuePod lhs, NUdf::TUnboxedValuePod rhs) const override {
36283664
if constexpr (IsArray) {
36293665
return Compare(lhs, rhs) < 0;
36303666
}
36313667

36323668
LOCAL_FCINFO(callInfo, 2);
36333669
Zero(*callInfo);
3634-
callInfo->flinfo = const_cast<FmgrInfo*>(&FInfoLess); // don't copy becase of ICompare isn't threadsafe
3670+
callInfo->flinfo = const_cast<FmgrInfo*>(&this->FInfoLess); // don't copy becase of ICompare isn't threadsafe
36353671
callInfo->nargs = 2;
36363672
callInfo->fncollation = DEFAULT_COLLATION_OID;
36373673
callInfo->isnull = false;
@@ -3654,15 +3690,15 @@ class TPgCompare : public NUdf::ICompare, public NUdf::TBlockItemComparatorBase<
36543690
ScalarDatumFromPod(rhs) :
36553691
PointerDatumFromPod(rhs), false };
36563692

3657-
auto x = FInfoLess.fn_addr(callInfo);
3693+
auto x = this->FInfoLess.fn_addr(callInfo);
36583694
Y_ENSURE(!callInfo->isnull);
36593695
return DatumGetBool(x);
36603696
}
36613697

36623698
int Compare(NUdf::TUnboxedValuePod lhs, NUdf::TUnboxedValuePod rhs) const override {
36633699
LOCAL_FCINFO(callInfo, 2);
36643700
Zero(*callInfo);
3665-
callInfo->flinfo = const_cast<FmgrInfo*>(&FInfoCompare); // don't copy becase of ICompare isn't threadsafe
3701+
callInfo->flinfo = const_cast<FmgrInfo*>(&this->FInfoCompare); // don't copy becase of ICompare isn't threadsafe
36663702
callInfo->nargs = 2;
36673703
callInfo->fncollation = DEFAULT_COLLATION_OID;
36683704
callInfo->isnull = false;
@@ -3685,15 +3721,25 @@ class TPgCompare : public NUdf::ICompare, public NUdf::TBlockItemComparatorBase<
36853721
ScalarDatumFromPod(rhs) :
36863722
PointerDatumFromPod(rhs), false };
36873723

3688-
auto x = FInfoCompare.fn_addr(callInfo);
3724+
auto x = this->FInfoCompare.fn_addr(callInfo);
36893725
Y_ENSURE(!callInfo->isnull);
36903726
return DatumGetInt32(x);
36913727
}
3728+
};
3729+
3730+
template <bool PassByValue, bool IsArray>
3731+
class TPgCompareItem : public TPgCompareBase<PassByValue, IsArray>, public NUdf::TBlockItemComparatorBase<TPgCompareItem<PassByValue, IsArray>, true> {
3732+
public:
3733+
using TBase = TPgCompareBase<PassByValue, IsArray>;
3734+
3735+
TPgCompareItem(const NYql::NPg::TTypeDesc& typeDesc)
3736+
: TBase(typeDesc)
3737+
{}
36923738

36933739
i64 DoCompare(NUdf::TBlockItem lhs, NUdf::TBlockItem rhs) const {
36943740
LOCAL_FCINFO(callInfo, 2);
36953741
Zero(*callInfo);
3696-
callInfo->flinfo = const_cast<FmgrInfo*>(&FInfoCompare); // don't copy becase of ICompare isn't threadsafe
3742+
callInfo->flinfo = const_cast<FmgrInfo*>(&this->FInfoCompare); // don't copy becase of ICompare isn't threadsafe
36973743
callInfo->nargs = 2;
36983744
callInfo->fncollation = DEFAULT_COLLATION_OID;
36993745
callInfo->isnull = false;
@@ -3704,7 +3750,7 @@ class TPgCompare : public NUdf::ICompare, public NUdf::TBlockItemComparatorBase<
37043750
ScalarDatumFromItem(rhs) :
37053751
PointerDatumFromItem(rhs), false };
37063752

3707-
auto x = FInfoCompare.fn_addr(callInfo);
3753+
auto x = this->FInfoCompare.fn_addr(callInfo);
37083754
Y_ENSURE(!callInfo->isnull);
37093755
return DatumGetInt32(x);
37103756
}
@@ -3716,7 +3762,7 @@ class TPgCompare : public NUdf::ICompare, public NUdf::TBlockItemComparatorBase<
37163762

37173763
LOCAL_FCINFO(callInfo, 2);
37183764
Zero(*callInfo);
3719-
callInfo->flinfo = const_cast<FmgrInfo*>(&FInfoEquals); // don't copy becase of ICompare isn't threadsafe
3765+
callInfo->flinfo = const_cast<FmgrInfo*>(&this->FInfoEquals); // don't copy becase of ICompare isn't threadsafe
37203766
callInfo->nargs = 2;
37213767
callInfo->fncollation = DEFAULT_COLLATION_OID;
37223768
callInfo->isnull = false;
@@ -3727,7 +3773,7 @@ class TPgCompare : public NUdf::ICompare, public NUdf::TBlockItemComparatorBase<
37273773
ScalarDatumFromItem(rhs) :
37283774
PointerDatumFromItem(rhs), false };
37293775

3730-
auto x = FInfoEquals.fn_addr(callInfo);
3776+
auto x = this->FInfoEquals.fn_addr(callInfo);
37313777
Y_ENSURE(!callInfo->isnull);
37323778
return DatumGetBool(x);
37333779
}
@@ -3739,7 +3785,7 @@ class TPgCompare : public NUdf::ICompare, public NUdf::TBlockItemComparatorBase<
37393785

37403786
LOCAL_FCINFO(callInfo, 2);
37413787
Zero(*callInfo);
3742-
callInfo->flinfo = const_cast<FmgrInfo*>(&FInfoLess); // don't copy becase of ICompare isn't threadsafe
3788+
callInfo->flinfo = const_cast<FmgrInfo*>(&this->FInfoLess); // don't copy becase of ICompare isn't threadsafe
37433789
callInfo->nargs = 2;
37443790
callInfo->fncollation = DEFAULT_COLLATION_OID;
37453791
callInfo->isnull = false;
@@ -3750,15 +3796,10 @@ class TPgCompare : public NUdf::ICompare, public NUdf::TBlockItemComparatorBase<
37503796
ScalarDatumFromItem(rhs) :
37513797
PointerDatumFromItem(rhs), false };
37523798

3753-
auto x = FInfoLess.fn_addr(callInfo);
3799+
auto x = this->FInfoLess.fn_addr(callInfo);
37543800
Y_ENSURE(!callInfo->isnull);
37553801
return DatumGetBool(x);
37563802
}
3757-
3758-
private:
3759-
const NYql::NPg::TTypeDesc TypeDesc;
3760-
3761-
FmgrInfo FInfoLess, FInfoCompare, FInfoEquals;
37623803
};
37633804

37643805
NUdf::ICompare::TPtr MakePgCompare(const NMiniKQL::TPgType* type) {
@@ -3775,11 +3816,11 @@ NUdf::ICompare::TPtr MakePgCompare(const NMiniKQL::TPgType* type) {
37753816
NUdf::IBlockItemComparator::TPtr MakePgItemComparator(ui32 typeId) {
37763817
const auto& typeDesc = NYql::NPg::LookupType(typeId);
37773818
if (typeDesc.PassByValue) {
3778-
return new TPgCompare<true, false>(typeDesc);
3819+
return new TPgCompareItem<true, false>(typeDesc);
37793820
} else if (typeDesc.TypeId == typeDesc.ArrayTypeId) {
3780-
return new TPgCompare<false, true>(typeDesc);
3821+
return new TPgCompareItem<false, true>(typeDesc);
37813822
} else {
3782-
return new TPgCompare<false, false>(typeDesc);
3823+
return new TPgCompareItem<false, false>(typeDesc);
37833824
}
37843825
}
37853826

@@ -3959,7 +4000,7 @@ class TPgBuilderImpl : public NUdf::IPgBuilder {
39594000

39604001
NUdf::TStringRef AsCStringBuffer(const NUdf::TUnboxedValue& value) const override {
39614002
auto x = (const char*)PointerDatumFromPod(value);
3962-
return { x, strlen(x) + 1};
4003+
return { x, ui32(strlen(x) + 1)};
39634004
}
39644005

39654006
NUdf::TStringRef AsTextBuffer(const NUdf::TUnboxedValue& value) const override {

ydb/library/yql/parser/pg_wrapper/generate_kernels.py

100644100755
+3
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,15 @@ def main():
355355
'\n'
356356
'extern "C" {\n'
357357
'\n'
358+
'Y_PRAGMA_DIAGNOSTIC_PUSH\n'
359+
'Y_PRAGMA("GCC diagnostic ignored \\"-Wreturn-type-c-linkage\\"")\n'
358360
'#ifdef USE_SLOW_PG_KERNELS\n'
359361
'#include "pg_kernels.slow.INDEX.inc"\n'
360362
'#else\n'
361363
'#include "pg_proc_policies.INDEX.inc"\n'
362364
'#include "pg_kernels.INDEX.inc"\n'
363365
'#endif\n'
366+
'Y_PRAGMA_DIAGNOSTIC_POP\n'
364367
'\n'
365368
'}\n'
366369
'\n'

ydb/library/yql/parser/pg_wrapper/pg_aggs.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ namespace NYql {
2828

2929
extern "C" {
3030

31+
Y_PRAGMA_DIAGNOSTIC_PUSH
32+
Y_PRAGMA("GCC diagnostic ignored \"-Wreturn-type-c-linkage\"")
3133
#ifdef USE_SLOW_PG_KERNELS
3234
#include "pg_aggs.slow.inc"
3335
#else
3436
#include "pg_proc_policies.all.inc"
3537
#include "pg_aggs.inc"
3638
#endif
39+
Y_PRAGMA_DIAGNOSTIC_POP
3740

3841
}
3942

0 commit comments

Comments
 (0)