Skip to content

Commit e44f557

Browse files
committed
refactor: replace std::any placeholder with Literal
Literal can be used for partition values and default values
1 parent f2a79a1 commit e44f557

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/iceberg/manifest_entry.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919

2020
#pragma once
2121

22-
#include <any>
2322
#include <cstdint>
2423
#include <map>
2524
#include <memory>
2625
#include <optional>
2726
#include <string>
2827
#include <vector>
2928

29+
#include "iceberg/expression/literal.h"
3030
#include "iceberg/file_format.h"
3131
#include "iceberg/iceberg_export.h"
3232
#include "iceberg/result.h"
@@ -77,9 +77,8 @@ struct ICEBERG_EXPORT DataFile {
7777
FileFormatType file_format;
7878
/// Field id: 102
7979
/// Partition data tuple, schema based on the partition spec output using partition
80-
/// field ids for the struct field ids
81-
/// TODO(zhjwpku): use StructLike to represent partition data tuple
82-
std::any partition;
80+
/// field ids
81+
std::vector<Literal> partition;
8382
/// Field id: 103
8483
/// Number of records in this file, or the cardinality of a deletion vector
8584
int64_t record_count = 0;

src/iceberg/schema_util.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
#pragma once
2121

22-
#include <any>
2322
#include <memory>
2423
#include <string>
2524
#include <variant>
2625
#include <vector>
2726

27+
#include "iceberg/expression/literal.h"
2828
#include "iceberg/iceberg_export.h"
2929
#include "iceberg/result.h"
3030
#include "iceberg/type_fwd.h"
@@ -48,14 +48,13 @@ struct ICEBERG_EXPORT FieldProjection {
4848
kNull,
4949
};
5050

51-
/// \brief The field index in the source schema on the same nesting level when
52-
/// `kind` is `kProjected`.
53-
using SourceFieldIndex = size_t;
54-
/// \brief A literal value used when `kind` is `kConstant` or `kDefault`.
55-
/// TODO(gangwu): replace it with a specifically defined literal type
56-
using Literal = std::any;
5751
/// \brief A variant to indicate how to set the value of the field.
58-
using From = std::variant<std::monostate, SourceFieldIndex, Literal>;
52+
/// \note `std::monostate` is used to indicate that the field is not projected.
53+
/// \note `size_t` is used to indicate the field index in the source schema on the same
54+
/// nesting level when `kind` is `kProjected`.
55+
/// \note `Literal` is used to indicate the value of the field when `kind` is
56+
/// `kConstant` or `kDefault`.
57+
using From = std::variant<std::monostate, size_t, Literal>;
5958

6059
/// \brief Format-specific attributes for the field.
6160
/// For example, for Parquet it might store column id and level info of the projected

0 commit comments

Comments
 (0)