Skip to content

refactor: replace std::any placeholder with Literal #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/iceberg/manifest_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

#pragma once

#include <any>
#include <cstdint>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <vector>

#include "iceberg/expression/literal.h"
#include "iceberg/file_format.h"
#include "iceberg/iceberg_export.h"
#include "iceberg/result.h"
Expand Down Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ok to me, and should we extract a Literals or StructLike type using Vector<Literal>, or just leave it here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add an optimized data structure for single value partition later or simply add something like https://github.com/apache/arrow/blob/main/cpp/src/arrow/util/small_vector.h

/// Field id: 103
/// Number of records in this file, or the cardinality of a deletion vector
int64_t record_count = 0;
Expand Down
15 changes: 7 additions & 8 deletions src/iceberg/schema_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
Loading