iceberg-cpp
Loading...
Searching...
No Matches
transform_util.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
24
25#include <cstdint>
26#include <string>
27
29#include "iceberg/result.h"
30
31namespace iceberg::internal {
32
33inline Status ValidateBucketTransformParameter(int32_t num_buckets) {
34 if (num_buckets <= 0) {
35 return InvalidArgument("Number of buckets must be positive, got {}", num_buckets);
36 }
37 return {};
38}
39
40inline Status ValidateTruncateTransformParameter(int32_t width) {
41 if (width <= 0) {
42 return InvalidArgument("Width must be positive, got {}", width);
43 }
44 return {};
45}
46
47} // namespace iceberg::internal
48
49namespace iceberg {
50
51class ICEBERG_EXPORT TransformUtil {
52 public:
59 static std::string HumanYear(int32_t year);
60
67 static std::string HumanMonth(int32_t month);
68
75 static std::string HumanDay(int32_t day_ordinal);
76
83 static std::string HumanHour(int32_t hour_ordinal);
84
97 static std::string HumanTime(int64_t micros_from_midnight);
98
109 static std::string HumanTimestamp(int64_t timestamp_micros);
110
122 static std::string HumanTimestampNs(int64_t timestamp_nanos);
123
135 static std::string HumanTimestampWithZone(int64_t timestamp_micros);
136
149 static std::string HumanTimestampNsWithZone(int64_t timestamp_nanos);
150};
151
152} // namespace iceberg
Definition transform_util.h:51
static std::string HumanMonth(int32_t month)
Returns a human-readable string for a month.
static std::string HumanTimestamp(int64_t timestamp_micros)
Returns a string representation of a timestamp in microseconds.
static std::string HumanTime(int64_t micros_from_midnight)
Outputs this time as a String, such as 10:15.
static std::string HumanHour(int32_t hour_ordinal)
Returns a human-readable string for the given hour ordinal.
static std::string HumanTimestampWithZone(int64_t timestamp_micros)
Returns a human-readable string representation of a timestamp with a time zone.
static std::string HumanDay(int32_t day_ordinal)
Returns a human-readable string for the given day ordinal.
static std::string HumanTimestampNsWithZone(int64_t timestamp_nanos)
Returns a string representation of a timestamp in nanoseconds with a time zone.
static std::string HumanTimestampNs(int64_t timestamp_nanos)
Returns a string representation of a timestamp in nanoseconds.
static std::string HumanYear(int32_t year)
Returns a human-readable string for a year.
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:33
Define Result, Status, and error helpers.