Skip to content

Commit 04ff61b

Browse files
author
Innocent
committed
set or unary operation helper
1 parent 3feca74 commit 04ff61b

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/iceberg/expression/json_serde.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,30 @@ constexpr std::string_view kTypeIsNan = "is-nan";
5454
constexpr std::string_view kTypeNotNan = "not-nan";
5555
} // namespace
5656

57+
/// Check if an operation is a unary predicate (no values)
58+
bool IsUnaryOperation(Expression::Operation op) {
59+
switch (op) {
60+
case Expression::Operation::kIsNull:
61+
case Expression::Operation::kNotNull:
62+
case Expression::Operation::kIsNan:
63+
case Expression::Operation::kNotNan:
64+
return true;
65+
default:
66+
return false;
67+
}
68+
}
69+
70+
/// Check if an operation is a set predicate (multiple values)
71+
bool IsSetOperation(Expression::Operation op) {
72+
switch (op) {
73+
case Expression::Operation::kIn:
74+
case Expression::Operation::kNotIn:
75+
return true;
76+
default:
77+
return false;
78+
}
79+
}
80+
5781
/// \brief Converts a JSON type string to an Expression::Operation.
5882
///
5983
/// \param type_str The JSON type string

src/iceberg/expression/json_serde_internal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,10 @@ ICEBERG_EXPORT Result<Expression::Operation> OperationTypeFromString(
6161
/// \return The operation type string (e.g., "eq", "lt-eq", "is-null")
6262
ICEBERG_EXPORT std::string_view ToStringOperationType(Expression::Operation op);
6363

64+
/// Check if an operation is a unary predicate (no values)
65+
ICEBERG_EXPORT bool IsUnaryOperation(Expression::Operation op);
66+
67+
/// Check if an operation is a set predicate (multiple values)
68+
ICEBERG_EXPORT bool IsSetOperation(Expression::Operation op);
69+
6470
} // namespace iceberg

0 commit comments

Comments
 (0)