iceberg-cpp
Loading...
Searching...
No Matches
transform_function.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
23
24#include "iceberg/transform.h"
25
26namespace iceberg {
28class ICEBERG_EXPORT IdentityTransform : public TransformFunction {
29 public:
31 explicit IdentityTransform(std::shared_ptr<Type> const& source_type);
32
34 Result<Literal> Transform(const Literal& literal) override;
35
37 std::shared_ptr<Type> ResultType() const override;
38
42 static Result<std::unique_ptr<TransformFunction>> Make(
43 std::shared_ptr<Type> const& source_type);
44};
45
47class ICEBERG_EXPORT BucketTransform : public TransformFunction {
48 public:
51 BucketTransform(std::shared_ptr<Type> const& source_type, int32_t num_buckets);
52
57 Result<Literal> Transform(const Literal& literal) override;
58
60 std::shared_ptr<Type> ResultType() const override;
61
63 int32_t num_buckets() const { return num_buckets_; }
64
69 static Result<std::unique_ptr<TransformFunction>> Make(
70 std::shared_ptr<Type> const& source_type, int32_t num_buckets);
71
72 private:
73 int32_t num_buckets_;
74};
75
77class ICEBERG_EXPORT TruncateTransform : public TransformFunction {
78 public:
81 TruncateTransform(std::shared_ptr<Type> const& source_type, int32_t width);
82
84 Result<Literal> Transform(const Literal& literal) override;
85
87 std::shared_ptr<Type> ResultType() const override;
88
90 int32_t width() const { return width_; }
91
96 static Result<std::unique_ptr<TransformFunction>> Make(
97 std::shared_ptr<Type> const& source_type, int32_t width);
98
99 private:
100 int32_t width_;
101};
102
105class ICEBERG_EXPORT YearTransform : public TransformFunction {
106 public:
108 explicit YearTransform(std::shared_ptr<Type> const& source_type);
109
111 Result<Literal> Transform(const Literal& literal) override;
112
114 std::shared_ptr<Type> ResultType() const override;
115
119 static Result<std::unique_ptr<TransformFunction>> Make(
120 std::shared_ptr<Type> const& source_type);
121};
122
125class ICEBERG_EXPORT MonthTransform : public TransformFunction {
126 public:
128 explicit MonthTransform(std::shared_ptr<Type> const& source_type);
129
131 Result<Literal> Transform(const Literal& literal) override;
132
134 std::shared_ptr<Type> ResultType() const override;
135
139 static Result<std::unique_ptr<TransformFunction>> Make(
140 std::shared_ptr<Type> const& source_type);
141};
142
145class ICEBERG_EXPORT DayTransform : public TransformFunction {
146 public:
148 explicit DayTransform(std::shared_ptr<Type> const& source_type);
149
151 Result<Literal> Transform(const Literal& literal) override;
152
158 std::shared_ptr<Type> ResultType() const override;
159
163 static Result<std::unique_ptr<TransformFunction>> Make(
164 std::shared_ptr<Type> const& source_type);
165};
166
169class ICEBERG_EXPORT HourTransform : public TransformFunction {
170 public:
172 explicit HourTransform(std::shared_ptr<Type> const& source_type);
173
175 Result<Literal> Transform(const Literal& literal) override;
176
178 std::shared_ptr<Type> ResultType() const override;
179
183 static Result<std::unique_ptr<TransformFunction>> Make(
184 std::shared_ptr<Type> const& source_type);
185};
186
188class ICEBERG_EXPORT VoidTransform : public TransformFunction {
189 public:
191 explicit VoidTransform(std::shared_ptr<Type> const& source_type);
192
194 Result<Literal> Transform(const Literal& literal) override;
195
197 std::shared_ptr<Type> ResultType() const override;
198
202 static Result<std::unique_ptr<TransformFunction>> Make(
203 std::shared_ptr<Type> const& source_type);
204};
205
206} // namespace iceberg
Bucket transform that hashes input values into N buckets.
Definition transform_function.h:47
int32_t num_buckets() const
Returns the number of buckets.
Definition transform_function.h:63
Day transform that extracts the number of days from timestamp inputs since the epoch.
Definition transform_function.h:145
Hour transform that extracts the number of hours from timestamp inputs since the epoch.
Definition transform_function.h:169
Identity transform that returns the input unchanged.
Definition transform_function.h:28
Literal is a literal value that is associated with a primitive type.
Definition literal.h:39
Month transform that extracts the number of months from timestamp inputs since the epoch.
Definition transform_function.h:125
A transform function used for partitioning.
Definition transform.h:251
Represents a transform used in partitioning or sorting in Iceberg.
Definition transform.h:90
Truncate transform that truncates values to a specified width.
Definition transform_function.h:77
int32_t width() const
Returns the width to truncate to.
Definition transform_function.h:90
Void transform that discards the input and always returns null.
Definition transform_function.h:188
Year transform that extracts the number of years from timestamp inputs since the epoch.
Definition transform_function.h:105