22 namespace foreign_storage {
27 virtual void validate(std::shared_ptr<parquet::Statistics>
stats,
31 template <
typename D,
typename T>
33 auto [min_value, max_value] = get_min_max_bounds<D>();
34 return value >= min_value && value <= max_value;
47 const std::string& min_value,
48 const std::string& max_value,
49 const std::string& encountered_value) {
50 std::stringstream error_message;
51 error_message <<
"Parquet column contains values that are outside the range of the "
53 "type. Consider using a wider column type. Min allowed value: "
54 << min_value <<
". Max allowed value: " << max_value
55 <<
". Encountered value: " << encountered_value <<
".";
56 throw std::runtime_error(error_message.str());
61 static_assert(std::is_integral<T>::value && std::is_signed<T>::value,
62 "TimestampBoundsValidator is only defined for signed integral types.");
81 return check_bounds<int32_t>(value);
83 return check_bounds<int64_t>(value);
95 return getMinMaxBoundsAsStrings<int32_t>(column_type);
97 return getMinMaxBoundsAsStrings<int64_t>(column_type);
104 template <
typename D>
107 auto [min_value, max_value] = get_min_max_bounds<D>();
113 template <
typename T>
115 static_assert(std::is_integral<T>::value,
116 "IntegralFixedLengthBoundsValidator is only defined for integral types.");
119 template <
typename D>
123 if (std::is_signed<T>::value) {
125 min_allowed_value, max_allowed_value,
std::to_string(data_value));
140 return checkBounds<int8_t>(value);
142 return checkBounds<int16_t>(value);
144 return checkBounds<int32_t>(value);
146 return checkBounds<int64_t>(value);
158 return getMinMaxBoundsAsStrings<int8_t>();
160 return getMinMaxBoundsAsStrings<int16_t>();
162 return getMinMaxBoundsAsStrings<int32_t>();
164 return getMinMaxBoundsAsStrings<int64_t>();
178 template <
typename D,
180 std::enable_if_t<std::is_signed<TT>::value,
int> = 0>
182 return check_bounds<D>(value);
192 template <
typename D,
194 std::enable_if_t<!std::is_signed<TT>::value,
int> = 0>
196 auto [min_value, max_value] = get_min_max_bounds<D>();
197 auto signed_value =
static_cast<D
>(value);
198 return signed_value >= 0 && signed_value <= max_value;
201 template <
typename D>
203 auto [min_value, max_value] = get_min_max_bounds<D>();
208 template <
typename T,
bool is_in_seconds = true>
211 std::is_integral<T>::value && std::is_signed<T>::value,
212 "DateInSecondsBoundsValidator is only defined for signed integral types.");
215 template <
typename D>
231 return checkBounds<int32_t>(value);
233 return checkBounds<int16_t>(value);
245 return getMinMaxBoundsAsStrings<int32_t>(column_type);
247 return getMinMaxBoundsAsStrings<int16_t>(column_type);
254 template <
typename D>
256 auto [min_value, max_value] = get_min_max_bounds<D>();
260 return value >= min_value && value <= max_value;
264 template <
typename D>
267 auto [min_value, max_value] = get_min_max_bounds<D>();
273 template <
typename T>
276 template <
typename T>
279 template <
typename T>
281 static_assert(std::is_floating_point<T>::value,
282 "FloatPointValidator is only defined for floating point types.");
285 template <
typename D>
290 min_allowed_value, max_allowed_value,
std::to_string(data_value));
299 return checkBounds<float>(value);
301 return checkBounds<double>(value);
313 return getMinMaxBoundsAsStrings<float>();
315 return getMinMaxBoundsAsStrings<double>();
322 template <
typename D>
324 return check_bounds<D>(value);
327 template <
typename D>
329 auto [min_value, max_value] = get_min_max_bounds<D>();
static std::pair< std::string, std::string > getMinMaxBoundsAsStrings(const SQLTypeInfo &column_type)
HOST DEVICE int get_size() const
std::string DatumToString(Datum d, const SQLTypeInfo &ti)
bool is_timestamp() const
static void validateValue(const D &data_value, const SQLTypeInfo &column_type)
static std::pair< std::string, std::string > getMinMaxBoundsAsStrings(const SQLTypeInfo &column_type)
static bool valueWithinBounds(const T &value, const SQLTypeInfo &column_type)
static std::pair< std::string, std::string > getMinMaxBoundsAsStrings(const SQLTypeInfo &column_type)
static void validateValue(const D &data_value, const SQLTypeInfo &column_type)
void throw_parquet_metadata_out_of_bounds_error(const std::string &min_value, const std::string &max_value, const std::string &encountered_value)
static std::pair< std::string, std::string > getMinMaxBoundsAsStrings()
static std::pair< std::string, std::string > getMinMaxBoundsAsStrings()
static bool checkBounds(const T &value)
static bool valueWithinBounds(const T &value, const SQLTypeInfo &column_type)
bool check_bounds(const T &value)
static std::pair< std::string, std::string > getMinMaxBoundsAsStrings(const SQLTypeInfo &column_type)
static bool checkBounds(const T &value)
static std::pair< std::string, std::string > getMinMaxBoundsAsStrings(const SQLTypeInfo &column_type)
static bool valueWithinBounds(const T &value, const SQLTypeInfo &column_type)
static void validateValue(const D &data_value, const SQLTypeInfo &column_type)
std::string datetime_to_string(const D ×tamp, const SQLTypeInfo &column_type)
static bool valueWithinBounds(const T &value, const SQLTypeInfo &column_type)
static std::pair< std::string, std::string > getMinMaxBoundsAsStrings(const SQLTypeInfo &column_type)
static bool checkBounds(const T &value)
Check bounds for value in signed case.
static void validateValue(const D &data_value, const SQLTypeInfo &column_type)