Skip to content

Commit d4d8b6b

Browse files
committed
Some code skeleton for Unary/Binary Ref
1 parent 934e16b commit d4d8b6b

File tree

6 files changed

+445
-64
lines changed

6 files changed

+445
-64
lines changed

src/iceberg/expression/common.h

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,96 @@
2222
#include <memory>
2323
#include <string>
2424

25-
#include "iceberg/result.h"
26-
2725
namespace iceberg {
28-
class Schema;
26+
27+
/// Operation types for expressions
28+
enum class Operation {
29+
kTrue,
30+
kFalse,
31+
kIsNull,
32+
kNotNull,
33+
kIsNan,
34+
kNotNan,
35+
kLt,
36+
kLtEq,
37+
kGt,
38+
kGtEq,
39+
kEq,
40+
kNotEq,
41+
kIn,
42+
kNotIn,
43+
kNot,
44+
kAnd,
45+
kOr,
46+
kStartsWith,
47+
kNotStartsWith,
48+
kCount,
49+
kCountStar,
50+
kMax,
51+
kMin
52+
};
53+
54+
/// \brief Returns whether the operation is a predicate operation.
55+
constexpr bool IsPredicate(Operation op) {
56+
switch (op) {
57+
case Operation::kTrue:
58+
case Operation::kFalse:
59+
case Operation::kIsNull:
60+
case Operation::kNotNull:
61+
case Operation::kIsNan:
62+
case Operation::kNotNan:
63+
case Operation::kLt:
64+
case Operation::kLtEq:
65+
case Operation::kGt:
66+
case Operation::kGtEq:
67+
case Operation::kEq:
68+
case Operation::kNotEq:
69+
case Operation::kIn:
70+
case Operation::kNotIn:
71+
case Operation::kNot:
72+
case Operation::kAnd:
73+
case Operation::kOr:
74+
case Operation::kStartsWith:
75+
case Operation::kNotStartsWith:
76+
return true;
77+
case Operation::kCount:
78+
case Operation::kCountStar:
79+
case Operation::kMax:
80+
case Operation::kMin:
81+
return false;
82+
}
83+
return false;
84+
}
85+
86+
constexpr bool IsUnaryPredicate(Operation op) {
87+
switch (op) {
88+
case Operation::kIsNull:
89+
case Operation::kNotNull:
90+
case Operation::kIsNan:
91+
case Operation::kNotNan:
92+
return true;
93+
default:
94+
return false;
95+
}
96+
}
97+
constexpr bool IsBinaryPredicate(Operation op) {
98+
switch (op) {
99+
case Operation::kLt:
100+
case Operation::kLtEq:
101+
case Operation::kGt:
102+
case Operation::kGtEq:
103+
case Operation::kEq:
104+
case Operation::kNotEq:
105+
case Operation::kIn:
106+
case Operation::kNotIn:
107+
case Operation::kAnd:
108+
case Operation::kOr:
109+
case Operation::kStartsWith:
110+
case Operation::kNotStartsWith:
111+
return true;
112+
default:
113+
return false;
114+
}
115+
}
29116

30117
} // namespace iceberg

0 commit comments

Comments
 (0)