Skip to content

Commit 83cc748

Browse files
authored
Correct work with TInt128 (win32 compile fix) (#7964)
1 parent 3151c0a commit 83cc748

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

ydb/library/yql/minikql/arrow/mkql_bit_utils.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ inline ui8 LoadByteUnaligned(const ui8* bitmap, size_t bitmapOffset) {
2626

2727
template<typename T>
2828
inline T SelectArg(ui8 isFirst, T first, T second) {
29-
static_assert(std::is_arithmetic<T>::value);
30-
if constexpr (std::is_floating_point<T>::value) {
31-
return isFirst ? first : second;
32-
} else {
29+
if constexpr (std::is_arithmetic_v<T> && !std::is_floating_point_v<T>) {
3330
// isFirst == 1 -> mask 0xFF..FF, isFirst == 0 -> mask 0x00..00
3431
T mask = -T(isFirst);
3532
return (first & mask) | (second & ~mask);
33+
} else {
34+
return isFirst ? first : second;
3635
}
3736
}
3837

@@ -160,4 +159,4 @@ using NYql::NUdf::CompressArray;
160159
using NYql::NUdf::DecompressToSparseBitmap;
161160

162161
} // namespace NMiniKQL
163-
} // namespace NKikimr
162+
} // namespace NKikimr

ydb/library/yql/minikql/comp_nodes/mkql_block_agg_minmax.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ struct TState;
8787

8888
template<typename TIn, bool IsMin>
8989
constexpr TIn InitialStateValue() {
90-
static_assert(std::is_arithmetic<TIn>::value);
9190
if constexpr (std::is_floating_point<TIn>::value) {
9291
static_assert(std::numeric_limits<TIn>::has_infinity && std::numeric_limits<TIn>::has_quiet_NaN);
9392
if constexpr (IsMin) {
@@ -102,12 +101,14 @@ constexpr TIn InitialStateValue() {
102101
} else {
103102
return -NYql::NDecimal::Inf();
104103
}
105-
} else {
104+
} else if constexpr (std::is_arithmetic<TIn>::value) {
106105
if constexpr (IsMin) {
107106
return std::numeric_limits<TIn>::max();
108107
} else {
109108
return std::numeric_limits<TIn>::min();
110109
}
110+
} else {
111+
static_assert(std::is_arithmetic<TIn>::value);
111112
}
112113
}
113114

ydb/library/yql/providers/yt/comp_nodes/dq/arrow_converter.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class TYsonFixedSizeBlockReader final : public IYsonBlockReaderWithNativeFlag<Na
401401
}
402402
}
403403

404-
if constexpr (std::is_integral_v<T>) {
404+
if constexpr (std::is_integral_v<T> && !std::is_same_v<T, NYql::NDecimal::TInt128>) {
405405
if constexpr (std::is_signed_v<T>) {
406406
YQL_ENSURE(buf.Current() == Int64Marker);
407407
buf.Next();
@@ -411,11 +411,13 @@ class TYsonFixedSizeBlockReader final : public IYsonBlockReaderWithNativeFlag<Na
411411
buf.Next();
412412
return NUdf::TBlockItem(T(buf.ReadVarUI64()));
413413
}
414+
} else if constexpr (std::is_floating_point_v<T>) {
415+
YQL_ENSURE(buf.Current() == DoubleMarker);
416+
buf.Next();
417+
return NUdf::TBlockItem(T(buf.NextDouble()));
418+
} else {
419+
static_assert(std::is_floating_point_v<T>);
414420
}
415-
416-
YQL_ENSURE(buf.Current() == DoubleMarker);
417-
buf.Next();
418-
return NUdf::TBlockItem(T(buf.NextDouble()));
419421
}
420422
};
421423

@@ -460,7 +462,8 @@ struct TYsonBlockReaderTraits {
460462
using TResult = IYsonBlockReader;
461463
template <bool Nullable>
462464
using TTuple = TYsonTupleBlockReader<Nullable, Native>;
463-
template <typename T, bool Nullable>
465+
// TODO: Implement reader for decimals
466+
template <typename T, bool Nullable, typename = std::enable_if_t<!std::is_same_v<T, NYql::NDecimal::TInt128> && (std::is_integral_v<T> || std::is_floating_point_v<T>)>>
464467
using TFixedSize = TYsonFixedSizeBlockReader<T, Nullable, Native>;
465468
template <typename TStringType, bool Nullable, NKikimr::NUdf::EDataSlot OriginalT>
466469
using TStrings = TYsonStringBlockReader<TStringType, Nullable, OriginalT, Native>;

ydb/library/yql/public/udf/arrow/block_reader.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,11 @@ std::unique_ptr<typename TTraits::TResult> MakeStringBlockReaderImpl(bool isOpti
553553
}
554554
}
555555

556+
template<typename TTraits>
557+
concept CanInstantiateBlockReaderForDecimal = requires {
558+
typename TTraits::template TFixedSize<NYql::NDecimal::TInt128, true>;
559+
};
560+
556561
template <typename TTraits>
557562
std::unique_ptr<typename TTraits::TResult> MakeBlockReaderImpl(const ITypeInfoHelper& typeInfoHelper, const TType* type, const IPgBuilder* pgBuilder) {
558563
const TType* unpacked = type;
@@ -672,8 +677,13 @@ std::unique_ptr<typename TTraits::TResult> MakeBlockReaderImpl(const ITypeInfoHe
672677
return TTraits::template MakeTzDate<TTzDatetime64>(isOptional);
673678
case NUdf::EDataSlot::TzTimestamp64:
674679
return TTraits::template MakeTzDate<TTzTimestamp64>(isOptional);
675-
case NUdf::EDataSlot::Decimal:
676-
return MakeFixedSizeBlockReaderImpl<TTraits, NYql::NDecimal::TInt128>(isOptional);
680+
case NUdf::EDataSlot::Decimal: {
681+
if constexpr (CanInstantiateBlockReaderForDecimal<TTraits>) {
682+
return MakeFixedSizeBlockReaderImpl<TTraits, NYql::NDecimal::TInt128>(isOptional);
683+
} else {
684+
Y_ENSURE(false, "Unsupported data slot");
685+
}
686+
}
677687
case NUdf::EDataSlot::Uuid:
678688
case NUdf::EDataSlot::DyNumber:
679689
Y_ENSURE(false, "Unsupported data slot");

0 commit comments

Comments
 (0)