iceberg-cpp
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
transform.h File Reference
#include <cstdint>
#include <memory>
#include <string_view>
#include <utility>
#include <variant>
#include "iceberg/expression/literal.h"
#include "iceberg/iceberg_export.h"
#include "iceberg/result.h"
#include "iceberg/type_fwd.h"
#include "iceberg/util/formattable.h"

Go to the source code of this file.

Classes

class  iceberg::Transform
 Represents a transform used in partitioning or sorting in Iceberg. More...
 
class  iceberg::TransformFunction
 A transform function used for partitioning. More...
 

Enumerations

enum class  iceberg::TransformType {
  kUnknown , kIdentity , kBucket , kTruncate ,
  kYear , kMonth , kDay , kHour ,
  kVoid
}
 Transform types used for partitioning. More...
 

Functions

ICEBERG_EXPORT constexpr std::string_view iceberg::TransformTypeToString (TransformType type)
 Get the relative transform name.
 
Result< std::shared_ptr< Transform > > iceberg::TransformFromString (std::string_view transform_str)
 Converts a string representation of a transform into a Transform instance.
 

Enumeration Type Documentation

◆ TransformType

enum class iceberg::TransformType
strong

Transform types used for partitioning.

Enumerator
kUnknown 

Used to represent some customized transform that can't be recognized or supported now.

kIdentity 

Equal to source value, unmodified.

kBucket 

Hash of value, mod N

kTruncate 

Value truncated to width W

kYear 

Extract a date or timestamp year, as years from 1970.

kMonth 

Extract a date or timestamp month, as months from 1970-01.

kDay 

Extract a date or timestamp day, as days from 1970-01-01.

kHour 

Extract a timestamp hour, as hours from 1970-01-01 00:00:00.

kVoid 

Always produces null

Function Documentation

◆ TransformFromString()

ICEBERG_EXPORT Result< std::shared_ptr< Transform > > iceberg::TransformFromString ( std::string_view  transform_str)

Converts a string representation of a transform into a Transform instance.

This function parses the provided string to identify the corresponding transform type (e.g., "identity", "year", "bucket[16]"), and creates a shared pointer to the corresponding Transform object. It supports both simple transforms (like "identity") and parameterized transforms (like "bucket[16]" or "truncate[4]").

Parameters
transform_strThe string representation of the transform type.
Returns
A Result containing either a shared pointer to the corresponding Transform instance or an Error if the string does not match any valid transform type.