Skip to content

Commit 9014d7f

Browse files
committed
feat: add transform project
Add Transform::Project for inclusive predicate projection This PR implements Transform::Project, which transforms a BoundPredicate to an inclusive predicate on partition values. StrictProject will be added in a separate PR to keep the review easier. Move template implementations of Expressions::In/NotIn/Predicate that take std::initializer_list<Literal> into the header file. Or the linker will shout out the following: Undefined symbols for architecture x86_64: "std::__1::shared_ptr<iceberg::UnboundPredicateImpl<iceberg::BoundReference>> iceberg::Expressions::In<iceberg::BoundReference>(std::__1::shared_ptr<iceberg::UnboundTerm<iceberg::BoundReference>>, std::initializer_list<iceberg::Literal>)", referenced from: iceberg::ProjectionUtil::FixInclusiveTimeProjection(std::__1::shared_ptr<iceberg::UnboundPredicateImpl<iceberg::BoundReference>> const&) in transform.cc.o
1 parent 9805fae commit 9014d7f

9 files changed

Lines changed: 1020 additions & 23 deletions

File tree

src/iceberg/expression/expressions.cc

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,6 @@ std::shared_ptr<UnboundPredicateImpl<BoundReference>> Expressions::In(
345345
return In<BoundReference>(Ref(std::move(name)), std::vector<Literal>(values));
346346
}
347347

348-
template <typename B>
349-
std::shared_ptr<UnboundPredicateImpl<B>> Expressions::In(
350-
std::shared_ptr<UnboundTerm<B>> expr, std::initializer_list<Literal> values) {
351-
return In<B>(std::move(expr), std::vector<Literal>(values));
352-
}
353-
354348
std::shared_ptr<UnboundPredicateImpl<BoundReference>> Expressions::NotIn(
355349
std::string name, std::vector<Literal> values) {
356350
return NotIn<BoundReference>(Ref(std::move(name)), std::move(values));
@@ -370,12 +364,6 @@ std::shared_ptr<UnboundPredicateImpl<BoundReference>> Expressions::NotIn(
370364
return NotIn<BoundReference>(Ref(std::move(name)), std::vector<Literal>(values));
371365
}
372366

373-
template <typename B>
374-
std::shared_ptr<UnboundPredicateImpl<B>> Expressions::NotIn(
375-
std::shared_ptr<UnboundTerm<B>> expr, std::initializer_list<Literal> values) {
376-
return NotIn<B>(expr, std::vector<Literal>(values));
377-
}
378-
379367
// Template implementations for generic predicate factory
380368

381369
std::shared_ptr<UnboundPredicateImpl<BoundReference>> Expressions::Predicate(
@@ -413,13 +401,6 @@ std::shared_ptr<UnboundPredicateImpl<B>> Expressions::Predicate(
413401
return pred;
414402
}
415403

416-
template <typename B>
417-
std::shared_ptr<UnboundPredicateImpl<B>> Expressions::Predicate(
418-
Expression::Operation op, std::shared_ptr<UnboundTerm<B>> expr,
419-
std::initializer_list<Literal> values) {
420-
return Predicate<B>(op, std::move(expr), std::vector<Literal>(values));
421-
}
422-
423404
template <typename B>
424405
std::shared_ptr<UnboundPredicateImpl<B>> Expressions::Predicate(
425406
Expression::Operation op, std::shared_ptr<UnboundTerm<B>> expr) {

src/iceberg/expression/expressions.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ class ICEBERG_EXPORT Expressions {
272272
/// \brief Create an IN predicate for an unbound term with initializer list.
273273
template <typename B>
274274
static std::shared_ptr<UnboundPredicateImpl<B>> In(
275-
std::shared_ptr<UnboundTerm<B>> expr, std::initializer_list<Literal> values);
275+
std::shared_ptr<UnboundTerm<B>> expr, std::initializer_list<Literal> values) {
276+
return In<B>(std::move(expr), std::vector<Literal>(values));
277+
}
276278

277279
/// \brief Create a NOT IN predicate for a field name.
278280
static std::shared_ptr<UnboundPredicateImpl<BoundReference>> NotIn(
@@ -290,7 +292,9 @@ class ICEBERG_EXPORT Expressions {
290292
/// \brief Create a NOT IN predicate for an unbound term with initializer list.
291293
template <typename B>
292294
static std::shared_ptr<UnboundPredicateImpl<B>> NotIn(
293-
std::shared_ptr<UnboundTerm<B>> expr, std::initializer_list<Literal> values);
295+
std::shared_ptr<UnboundTerm<B>> expr, std::initializer_list<Literal> values) {
296+
return NotIn<B>(expr, std::vector<Literal>(values));
297+
}
294298

295299
// Generic predicate factory
296300

@@ -320,7 +324,9 @@ class ICEBERG_EXPORT Expressions {
320324
template <typename B>
321325
static std::shared_ptr<UnboundPredicateImpl<B>> Predicate(
322326
Expression::Operation op, std::shared_ptr<UnboundTerm<B>> expr,
323-
std::initializer_list<Literal> values);
327+
std::initializer_list<Literal> values) {
328+
return Predicate<B>(op, std::move(expr), std::vector<Literal>(values));
329+
}
324330

325331
/// \brief Create a unary predicate for unbound term.
326332
template <typename B>

src/iceberg/expression/predicate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "iceberg/expression/expression.h"
2828
#include "iceberg/expression/literal.h"
2929
#include "iceberg/expression/term.h"
30+
#include "iceberg/iceberg_export.h"
3031

3132
namespace iceberg {
3233

0 commit comments

Comments
 (0)