WZhuo commented on code in PR #585:
URL: https://github.com/apache/iceberg-cpp/pull/585#discussion_r2929102082
##########
src/iceberg/util/truncate_util.cc:
##########
@@ -72,8 +159,85 @@ Literal TruncateLiteralImpl<TypeId::kBinary>(const Literal&
literal, int32_t wid
return Literal::Binary(std::vector<uint8_t>(data.begin(), data.begin() +
width));
}
+template <TypeId type_id>
+Result<Literal> TruncateLiteralMaxImpl(const Literal& literal, int32_t width) {
+ std::unreachable();
Review Comment:
Use `= delete` for unsupported types, give out errors in compile time.
##########
src/iceberg/util/truncate_util.cc:
##########
@@ -72,8 +159,85 @@ Literal TruncateLiteralImpl<TypeId::kBinary>(const Literal&
literal, int32_t wid
return Literal::Binary(std::vector<uint8_t>(data.begin(), data.begin() +
width));
}
+template <TypeId type_id>
+Result<Literal> TruncateLiteralMaxImpl(const Literal& literal, int32_t width) {
+ std::unreachable();
+}
+
+template <>
+Result<Literal> TruncateLiteralMaxImpl<TypeId::kString>(const Literal& literal,
+ int32_t width) {
+ const auto& str = std::get<std::string>(literal.value());
+ ICEBERG_ASSIGN_OR_RAISE(std::string truncated,
+ TruncateUtils::TruncateUTF8Max(str, width));
+ if (truncated == str) {
+ return literal;
+ }
Review Comment:
Indeed it is.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]