You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by fo...@apache.org on 2025/06/27 21:21:38 UTC
(iceberg-cpp) branch main updated: refactor: replace std::any placeholder with Literal (#130)
This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-cpp.git
The following commit(s) were added to refs/heads/main by this push:
new 3724aa2 refactor: replace std::any placeholder with Literal (#130)
3724aa2 is described below
commit 3724aa20689e20e08143620a0f173bcaf32975b3
Author: Gang Wu <us...@gmail.com>
AuthorDate: Sat Jun 28 05:21:34 2025 +0800
refactor: replace std::any placeholder with Literal (#130)
Literal can be used for partition values and default values
---
src/iceberg/manifest_entry.h | 7 +++----
src/iceberg/schema_util.h | 15 +++++++--------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/iceberg/manifest_entry.h b/src/iceberg/manifest_entry.h
index 43db00a..0b1355a 100644
--- a/src/iceberg/manifest_entry.h
+++ b/src/iceberg/manifest_entry.h
@@ -19,7 +19,6 @@
#pragma once
-#include <any>
#include <cstdint>
#include <map>
#include <memory>
@@ -27,6 +26,7 @@
#include <string>
#include <vector>
+#include "iceberg/expression/literal.h"
#include "iceberg/file_format.h"
#include "iceberg/iceberg_export.h"
#include "iceberg/result.h"
@@ -77,9 +77,8 @@ struct ICEBERG_EXPORT DataFile {
FileFormatType file_format;
/// Field id: 102
/// Partition data tuple, schema based on the partition spec output using partition
- /// field ids for the struct field ids
- /// TODO(zhjwpku): use StructLike to represent partition data tuple
- std::any partition;
+ /// field ids
+ std::vector<Literal> partition;
/// Field id: 103
/// Number of records in this file, or the cardinality of a deletion vector
int64_t record_count = 0;
diff --git a/src/iceberg/schema_util.h b/src/iceberg/schema_util.h
index 72b6b55..8ba21a7 100644
--- a/src/iceberg/schema_util.h
+++ b/src/iceberg/schema_util.h
@@ -19,12 +19,12 @@
#pragma once
-#include <any>
#include <memory>
#include <string>
#include <variant>
#include <vector>
+#include "iceberg/expression/literal.h"
#include "iceberg/iceberg_export.h"
#include "iceberg/result.h"
#include "iceberg/type_fwd.h"
@@ -48,14 +48,13 @@ struct ICEBERG_EXPORT FieldProjection {
kNull,
};
- /// \brief The field index in the source schema on the same nesting level when
- /// `kind` is `kProjected`.
- using SourceFieldIndex = size_t;
- /// \brief A literal value used when `kind` is `kConstant` or `kDefault`.
- /// TODO(gangwu): replace it with a specifically defined literal type
- using Literal = std::any;
/// \brief A variant to indicate how to set the value of the field.
- using From = std::variant<std::monostate, SourceFieldIndex, Literal>;
+ /// \note `std::monostate` is used to indicate that the field is not projected.
+ /// \note `size_t` is used to indicate the field index in the source schema on the same
+ /// nesting level when `kind` is `kProjected`.
+ /// \note `Literal` is used to indicate the value of the field when `kind` is
+ /// `kConstant` or `kDefault`.
+ using From = std::variant<std::monostate, size_t, Literal>;
/// \brief Format-specific attributes for the field.
/// For example, for Parquet it might store column id and level info of the projected