@@ -104,8 +104,10 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::IsNull(std::strin
104104template <typename B>
105105std::shared_ptr<UnboundPredicate<B>> Expressions::IsNull (
106106 std::shared_ptr<UnboundTerm<B>> expr) {
107- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kIsNull ,
108- std::move (expr));
107+ ICEBERG_ASSIGN_OR_THROW (
108+ auto pred,
109+ UnboundPredicate<B>::Make (Expression::Operation::kIsNull , std::move (expr)));
110+ return pred;
109111}
110112
111113std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::NotNull (std::string name) {
@@ -115,8 +117,10 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::NotNull(std::stri
115117template <typename B>
116118std::shared_ptr<UnboundPredicate<B>> Expressions::NotNull (
117119 std::shared_ptr<UnboundTerm<B>> expr) {
118- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kNotNull ,
119- std::move (expr));
120+ ICEBERG_ASSIGN_OR_THROW (
121+ auto pred,
122+ UnboundPredicate<B>::Make (Expression::Operation::kNotNull , std::move (expr)));
123+ return pred;
120124}
121125
122126std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::IsNaN (std::string name) {
@@ -126,8 +130,9 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::IsNaN(std::string
126130template <typename B>
127131std::shared_ptr<UnboundPredicate<B>> Expressions::IsNaN (
128132 std::shared_ptr<UnboundTerm<B>> expr) {
129- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kIsNan ,
130- std::move (expr));
133+ ICEBERG_ASSIGN_OR_THROW (auto pred, UnboundPredicate<B>::Make (
134+ Expression::Operation::kIsNan , std::move (expr)));
135+ return pred;
131136}
132137
133138std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::NotNaN (std::string name) {
@@ -137,8 +142,10 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::NotNaN(std::strin
137142template <typename B>
138143std::shared_ptr<UnboundPredicate<B>> Expressions::NotNaN (
139144 std::shared_ptr<UnboundTerm<B>> expr) {
140- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kNotNan ,
141- std::move (expr));
145+ ICEBERG_ASSIGN_OR_THROW (
146+ auto pred,
147+ UnboundPredicate<B>::Make (Expression::Operation::kNotNan , std::move (expr)));
148+ return pred;
142149}
143150
144151// Template implementations for comparison predicates
@@ -151,8 +158,10 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::LessThan(std::str
151158template <typename B>
152159std::shared_ptr<UnboundPredicate<B>> Expressions::LessThan (
153160 std::shared_ptr<UnboundTerm<B>> expr, Literal value) {
154- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kLt ,
155- std::move (expr), std::move (value));
161+ ICEBERG_ASSIGN_OR_THROW (
162+ auto pred, UnboundPredicate<B>::Make (Expression::Operation::kLt , std::move (expr),
163+ std::move (value)));
164+ return pred;
156165}
157166
158167std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::LessThanOrEqual (
@@ -163,8 +172,10 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::LessThanOrEqual(
163172template <typename B>
164173std::shared_ptr<UnboundPredicate<B>> Expressions::LessThanOrEqual (
165174 std::shared_ptr<UnboundTerm<B>> expr, Literal value) {
166- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kLtEq ,
167- std::move (expr), std::move (value));
175+ ICEBERG_ASSIGN_OR_THROW (
176+ auto pred, UnboundPredicate<B>::Make (Expression::Operation::kLtEq , std::move (expr),
177+ std::move (value)));
178+ return pred;
168179}
169180
170181std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::GreaterThan (
@@ -175,8 +186,10 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::GreaterThan(
175186template <typename B>
176187std::shared_ptr<UnboundPredicate<B>> Expressions::GreaterThan (
177188 std::shared_ptr<UnboundTerm<B>> expr, Literal value) {
178- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kGt ,
179- std::move (expr), std::move (value));
189+ ICEBERG_ASSIGN_OR_THROW (
190+ auto pred, UnboundPredicate<B>::Make (Expression::Operation::kGt , std::move (expr),
191+ std::move (value)));
192+ return pred;
180193}
181194
182195std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::GreaterThanOrEqual (
@@ -187,8 +200,10 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::GreaterThanOrEqua
187200template <typename B>
188201std::shared_ptr<UnboundPredicate<B>> Expressions::GreaterThanOrEqual (
189202 std::shared_ptr<UnboundTerm<B>> expr, Literal value) {
190- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kGtEq ,
191- std::move (expr), std::move (value));
203+ ICEBERG_ASSIGN_OR_THROW (
204+ auto pred, UnboundPredicate<B>::Make (Expression::Operation::kGtEq , std::move (expr),
205+ std::move (value)));
206+ return pred;
192207}
193208
194209std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::Equal (std::string name,
@@ -199,8 +214,10 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::Equal(std::string
199214template <typename B>
200215std::shared_ptr<UnboundPredicate<B>> Expressions::Equal (
201216 std::shared_ptr<UnboundTerm<B>> expr, Literal value) {
202- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kEq ,
203- std::move (expr), std::move (value));
217+ ICEBERG_ASSIGN_OR_THROW (
218+ auto pred, UnboundPredicate<B>::Make (Expression::Operation::kEq , std::move (expr),
219+ std::move (value)));
220+ return pred;
204221}
205222
206223std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::NotEqual (std::string name,
@@ -211,8 +228,10 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::NotEqual(std::str
211228template <typename B>
212229std::shared_ptr<UnboundPredicate<B>> Expressions::NotEqual (
213230 std::shared_ptr<UnboundTerm<B>> expr, Literal value) {
214- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kNotEq ,
215- std::move (expr), std::move (value));
231+ ICEBERG_ASSIGN_OR_THROW (
232+ auto pred, UnboundPredicate<B>::Make (Expression::Operation::kNotEq , std::move (expr),
233+ std::move (value)));
234+ return pred;
216235}
217236
218237// String predicates
@@ -225,9 +244,11 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::StartsWith(
225244template <typename B>
226245std::shared_ptr<UnboundPredicate<B>> Expressions::StartsWith (
227246 std::shared_ptr<UnboundTerm<B>> expr, std::string value) {
228- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kStartsWith ,
229- std::move (expr),
230- Literal::String (std::move (value)));
247+ ICEBERG_ASSIGN_OR_THROW (
248+ auto pred,
249+ UnboundPredicate<B>::Make (Expression::Operation::kStartsWith , std::move (expr),
250+ Literal::String (std::move (value))));
251+ return pred;
231252}
232253
233254std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::NotStartsWith (
@@ -238,9 +259,11 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::NotStartsWith(
238259template <typename B>
239260std::shared_ptr<UnboundPredicate<B>> Expressions::NotStartsWith (
240261 std::shared_ptr<UnboundTerm<B>> expr, std::string value) {
241- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kNotStartsWith ,
242- std::move (expr),
243- Literal::String (std::move (value)));
262+ ICEBERG_ASSIGN_OR_THROW (
263+ auto pred,
264+ UnboundPredicate<B>::Make (Expression::Operation::kNotStartsWith , std::move (expr),
265+ Literal::String (std::move (value))));
266+ return pred;
244267}
245268
246269// Template implementations for set predicates
@@ -253,8 +276,10 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::In(
253276template <typename B>
254277std::shared_ptr<UnboundPredicate<B>> Expressions::In (std::shared_ptr<UnboundTerm<B>> expr,
255278 std::vector<Literal> values) {
256- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kIn ,
257- std::move (expr), std::move (values));
279+ ICEBERG_ASSIGN_OR_THROW (
280+ auto pred, UnboundPredicate<B>::Make (Expression::Operation::kIn , std::move (expr),
281+ std::move (values)));
282+ return pred;
258283}
259284
260285std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::In (
@@ -276,8 +301,10 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::NotIn(
276301template <typename B>
277302std::shared_ptr<UnboundPredicate<B>> Expressions::NotIn (
278303 std::shared_ptr<UnboundTerm<B>> expr, std::vector<Literal> values) {
279- return std::make_shared<UnboundPredicate<B>>(Expression::Operation::kNotIn ,
280- std::move (expr), std::move (values));
304+ ICEBERG_ASSIGN_OR_THROW (
305+ auto pred, UnboundPredicate<B>::Make (Expression::Operation::kNotIn , std::move (expr),
306+ std::move (values)));
307+ return pred;
281308}
282309
283310std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::NotIn (
@@ -295,14 +322,16 @@ std::shared_ptr<UnboundPredicate<B>> Expressions::NotIn(
295322
296323std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::Predicate (
297324 Expression::Operation op, std::string name, Literal value) {
298- return std::make_shared<UnboundPredicate<BoundReference>>(op, Ref (std::move (name)),
299- std::move (value));
325+ ICEBERG_ASSIGN_OR_THROW (auto pred, UnboundPredicate<BoundReference>::Make (
326+ op, Ref (std::move (name)), std::move (value)));
327+ return pred;
300328}
301329
302330std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::Predicate (
303331 Expression::Operation op, std::string name, std::vector<Literal> values) {
304- return std::make_shared<UnboundPredicate<BoundReference>>(op, Ref (std::move (name)),
305- std::move (values));
332+ ICEBERG_ASSIGN_OR_THROW (auto pred, UnboundPredicate<BoundReference>::Make (
333+ op, Ref (std::move (name)), std::move (values)));
334+ return pred;
306335}
307336
308337std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::Predicate (
@@ -312,14 +341,18 @@ std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::Predicate(
312341
313342std::shared_ptr<UnboundPredicate<BoundReference>> Expressions::Predicate (
314343 Expression::Operation op, std::string name) {
315- return std::make_shared<UnboundPredicate<BoundReference>>(op, Ref (std::move (name)));
344+ ICEBERG_ASSIGN_OR_THROW (
345+ auto pred, UnboundPredicate<BoundReference>::Make (op, Ref (std::move (name))));
346+ return pred;
316347}
317348
318349template <typename B>
319350std::shared_ptr<UnboundPredicate<B>> Expressions::Predicate (
320351 Expression::Operation op, std::shared_ptr<UnboundTerm<B>> expr,
321352 std::vector<Literal> values) {
322- return std::make_shared<UnboundPredicate<B>>(op, std::move (expr), std::move (values));
353+ ICEBERG_ASSIGN_OR_THROW (
354+ auto pred, UnboundPredicate<B>::Make (op, std::move (expr), std::move (values)));
355+ return pred;
323356}
324357
325358template <typename B>
@@ -332,7 +365,8 @@ std::shared_ptr<UnboundPredicate<B>> Expressions::Predicate(
332365template <typename B>
333366std::shared_ptr<UnboundPredicate<B>> Expressions::Predicate (
334367 Expression::Operation op, std::shared_ptr<UnboundTerm<B>> expr) {
335- return std::make_shared<UnboundPredicate<B>>(op, std::move (expr));
368+ ICEBERG_ASSIGN_OR_THROW (auto pred, UnboundPredicate<B>::Make (op, std::move (expr)));
369+ return pred;
336370}
337371
338372// Constants
0 commit comments