iceberg-cpp
Loading...
Searching...
No Matches
metadata_columns.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 <limits>
26#include <memory>
27#include <set>
28#include <string_view>
29
30#include "iceberg/iceberg_export.h"
31#include "iceberg/result.h"
33#include "iceberg/type.h"
34
35namespace iceberg {
36
38struct ICEBERG_EXPORT MetadataColumns {
39 constexpr static int32_t kInt32Max = std::numeric_limits<int32_t>::max();
40
41 // IDs kInt32Max - (1-100) are used for metadata columns
42 constexpr static int32_t kFilePathColumnId = kInt32Max - 1;
43 inline static const SchemaField kFilePath = SchemaField::MakeRequired(
44 kFilePathColumnId, "_file", string(), "Path of the file in which a row is stored");
45
46 constexpr static int32_t kFilePositionColumnId = kInt32Max - 2;
47 inline static const SchemaField kRowPosition =
48 SchemaField::MakeRequired(kFilePositionColumnId, "_pos", int64(),
49 "Ordinal position of a row in the source data file");
50
51 constexpr static int32_t kIsDeletedColumnId = kInt32Max - 3;
52 inline static const SchemaField kIsDeleted = SchemaField::MakeRequired(
53 kIsDeletedColumnId, "_deleted", boolean(), "Whether the row has been deleted");
54
55 constexpr static int32_t kSpecIdColumnId = kInt32Max - 4;
56 inline static const SchemaField kSpecId =
57 SchemaField::MakeRequired(kSpecIdColumnId, "_spec_id", int32(),
58 "Spec ID used to track the file containing a row");
59
60 // The partition column type depends on all specs in the table
61 constexpr static int32_t kPartitionColumnId = kInt32Max - 5;
62 constexpr static std::string_view kPartitionColumnName = "_partition";
63 constexpr static std::string_view kPartitionColumnDoc =
64 "Partition to which a row belongs to";
65
66 constexpr static int32_t kContentOffsetColumnId = kInt32Max - 6;
67 constexpr static int32_t kContentSizeInBytesColumnId = kInt32Max - 7;
68
69 // IDs kInt32Max - (101-200) are used for reserved columns
70 constexpr static int32_t kDeleteFilePathColumnId = kInt32Max - 101;
71 inline static const SchemaField kDeleteFilePath =
72 SchemaField::MakeRequired(kDeleteFilePathColumnId, "file_path", string(),
73 "Path of a file in which a deleted row is stored");
74
75 constexpr static int32_t kDeleteFilePosColumnId = kInt32Max - 102;
76 inline static const SchemaField kDeleteFilePos =
77 SchemaField::MakeRequired(kDeleteFilePosColumnId, "pos", int64(),
78 "Ordinal position of a deleted row in the data file");
79
80 // The row column type depends on the table schema
81 constexpr static int32_t kDeleteFileRowColumnId = kInt32Max - 103;
82 constexpr static std::string_view kDeleteFileRowFieldName = "row";
83 constexpr static std::string_view kDeleteFileRowDoc = "Deleted row values";
84
85 constexpr static int32_t kChangeTypeColumnId = kInt32Max - 104;
86 inline static const SchemaField kChangeType = SchemaField::MakeRequired(
87 kChangeTypeColumnId, "_change_type", string(), "Record type in changelog");
88
89 constexpr static int32_t kChangeOrdinalColumnId = kInt32Max - 105;
90 inline static const SchemaField kChangeOrdinal = SchemaField::MakeOptional(
91 kChangeOrdinalColumnId, "_change_ordinal", int32(), "Change ordinal in changelog");
92
93 constexpr static int32_t kCommitSnapshotIdColumnId = kInt32Max - 106;
94 inline static const SchemaField kCommitSnapshotId = SchemaField::MakeOptional(
95 kCommitSnapshotIdColumnId, "_commit_snapshot_id", int64(), "Commit snapshot ID");
96
97 constexpr static int32_t kRowIdColumnId = kInt32Max - 107;
98 inline static const SchemaField kRowId =
99 SchemaField::MakeOptional(kRowIdColumnId, "_row_id", int64(),
100 "Implicit row ID that is automatically assigned");
101
102 constexpr static int32_t kLastUpdatedSequenceNumberColumnId = kInt32Max - 108;
103 inline static const SchemaField kLastUpdatedSequenceNumber = SchemaField::MakeOptional(
104 kLastUpdatedSequenceNumberColumnId, "_last_updated_sequence_number", int64(),
105 "Sequence number when the row was last updated");
106
108 static const std::set<int32_t>& MetadataFieldIds();
109
111 static bool IsMetadataColumn(std::string_view name);
112
114 static bool IsMetadataColumn(int32_t id);
115
121 static Result<const SchemaField*> MetadataColumn(std::string_view name);
122
124};
125
126} // namespace iceberg
A type combined with a name.
Definition schema_field.h:39
ICEBERG_EXPORT const std::shared_ptr< IntType > & int32()
Return an IntType instance.
ICEBERG_EXPORT const std::shared_ptr< LongType > & int64()
Return a LongType instance.
A class containing constants and utility methods for metadata columns.
Definition metadata_columns.h:38