wgtmac commented on code in PR #61:
URL: https://github.com/apache/iceberg-cpp/pull/61#discussion_r2040668421


##########
src/iceberg/transform.h:
##########
@@ -56,16 +57,133 @@ enum class TransformType {
   kVoid,
 };
 
+/// \brief Get the relative transform name
+ICEBERG_EXPORT constexpr std::string_view TransformTypeToString(TransformType 
type);
+
+/// \brief Represents a transform used in partitioning or sorting in Iceberg.
+///
+/// This class supports binding to a source type and instantiating the 
corresponding
+/// TransformFunction, as well as serialization-friendly introspection.
+class ICEBERG_EXPORT Transform : public util::Formattable {
+ public:
+  /// \brief Returns a shared singleton instance of the Identity transform.
+  ///
+  /// This transform leaves values unchanged and is commonly used for direct 
partitioning.
+  /// \return A shared pointer to the Identity transform.
+  static std::shared_ptr<Transform> Identity();
+
+  /// \brief Creates a shared instance of the Bucket transform.
+  ///
+  /// Buckets values using a hash modulo operation. Commonly used for 
distributing data.
+  /// \param num_buckets The number of buckets.
+  /// \return A shared pointer to the Bucket transform.
+  static std::shared_ptr<Transform> Bucket(int32_t num_buckets);
+
+  /// \brief Creates a shared instance of the Truncate transform.
+  ///
+  /// Truncates values to a fixed width (e.g., for strings or binary data).
+  /// \param width The width to truncate to.
+  /// \return A shared pointer to the Truncate transform.
+  static std::shared_ptr<Transform> Truncate(int32_t width);
+
+  /// \brief Creates a shared singleton instance of the Year transform.
+  ///
+  /// Extracts the year portion from a date or timestamp.
+  /// \return A shared pointer to the Year transform.
+  static std::shared_ptr<Transform> Year();
+
+  /// \brief Creates a shared singleton instance of the Month transform.
+  ///
+  /// Extracts the month portion from a date or timestamp.
+  /// \return A shared pointer to the Month transform.
+  static std::shared_ptr<Transform> Month();
+
+  /// \brief Creates a shared singleton instance of the Day transform.
+  ///
+  /// Extracts the day portion from a date or timestamp.
+  /// \return A shared pointer to the Day transform.
+  static std::shared_ptr<Transform> Day();
+
+  /// \brief Creates a shared singleton instance of the Hour transform.
+  ///
+  /// Extracts the hour portion from a timestamp.
+  /// \return A shared pointer to the Hour transform.
+  static std::shared_ptr<Transform> Hour();
+
+  /// \brief Creates a shared singleton instance of the Void transform.
+  ///
+  /// Ignores values and always returns null. Useful for testing or special 
cases.
+  /// \return A shared pointer to the Void transform.
+  static std::shared_ptr<Transform> Void();
+
+  /// \brief Returns the transform type.
+  TransformType transform_type() const;
+
+  /// \brief Binds this transform to a source type, returning a typed 
TransformFunction.
+  ///
+  /// This creates a concrete transform implementation based on the transform 
type and
+  /// parameter.
+  /// \param source_type The source column type to bind to.
+  /// \return A TransformFunction instance wrapped in `expected`, or an error 
on failure.
+  expected<std::unique_ptr<TransformFunction>, Error> Bind(

Review Comment:
   ```suggestion
     Result<std::unique_ptr<TransformFunction>> Bind(
   ```
   
   nit: we can leave these as-is and fix all together in a separate PR.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to