iceberg-cpp
Loading...
Searching...
No Matches
schema_util.h
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
22#include <memory>
23#include <string>
24#include <variant>
25#include <vector>
26
27#include "iceberg/expression/literal.h"
28#include "iceberg/iceberg_export.h"
29#include "iceberg/result.h"
30#include "iceberg/type_fwd.h"
31
32namespace iceberg {
33
35struct ICEBERG_EXPORT FieldProjection {
37 enum class Kind {
40 kProjected,
42 kMetadata,
44 kConstant,
46 kDefault,
48 kNull,
49 };
50
57 using From = std::variant<std::monostate, size_t, Literal>;
58
63 virtual ~ExtraAttributes() = default;
64 };
65
71 std::vector<FieldProjection> children;
73 std::shared_ptr<ExtraAttributes> attributes;
74};
75
77struct ICEBERG_EXPORT SchemaProjection {
78 std::vector<FieldProjection> fields;
79};
80
91ICEBERG_EXPORT Result<SchemaProjection> Project(const Schema& expected_schema,
92 const Schema& source_schema,
93 bool prune_source);
94
95ICEBERG_EXPORT std::string_view ToString(FieldProjection::Kind kind);
96ICEBERG_EXPORT std::string ToString(const FieldProjection& projection);
97ICEBERG_EXPORT std::string ToString(const SchemaProjection& projection);
98
99} // namespace iceberg
A schema for a Table.
Definition schema.h:49
Format-specific attributes for the field. For example, for Parquet it might store column id and level...
Definition schema_util.h:62
A field schema partner to carry projection information.
Definition schema_util.h:35
std::variant< std::monostate, size_t, Literal > From
A variant to indicate how to set the value of the field.
Definition schema_util.h:57
std::vector< FieldProjection > children
The children of the field if it is a nested field.
Definition schema_util.h:71
Kind kind
The kind of projection of the field it partners with.
Definition schema_util.h:67
From from
The source to set the value of the field.
Definition schema_util.h:69
Kind
How the field is projected.
Definition schema_util.h:37
std::shared_ptr< ExtraAttributes > attributes
Format-specific attributes for the field.
Definition schema_util.h:73
A schema partner to carry projection information.
Definition schema_util.h:77