Skip to content

Commit 0ce9818

Browse files
author
xiao.dong
committed
fix cast
1 parent c20b738 commit 0ce9818

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/iceberg/expression/inclusive_metrics_evaluator.cc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
8686
if (ContainsNullsOnly(id)) {
8787
return kRowCannotMatch;
8888
}
89-
if (internal::checked_pointer_cast<BoundReference>(expr) == nullptr) {
89+
if (std::dynamic_pointer_cast<BoundReference>(expr) == nullptr) {
9090
return kRowsMightMatch;
9191
}
9292
auto it = data_file_.nan_value_counts.find(id);
@@ -97,7 +97,7 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
9797
}
9898

9999
Result<bool> NotNaN(const std::shared_ptr<Bound>& expr) override {
100-
if (internal::checked_pointer_cast<BoundReference>(expr) == nullptr) {
100+
if (std::dynamic_pointer_cast<BoundReference>(expr) == nullptr) {
101101
// identity transforms are already removed by this time
102102
return kRowsMightMatch;
103103
}
@@ -291,13 +291,13 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
291291

292292
Result<bool> StartsWith(const std::shared_ptr<Bound>& expr,
293293
const Literal& lit) override {
294-
// auto transform = internal::checked_pointer_cast<BoundTransform>(expr);
295-
// if (transform != nullptr &&
296-
// transform->transform()->transform_type() != TransformType::kIdentity) {
297-
// // truncate must be rewritten in binding. the result is either always or never
298-
// // compatible
299-
// return kRowsMightMatch;
300-
// }
294+
auto transform = std::dynamic_pointer_cast<BoundTransform>(expr);
295+
if (transform != nullptr &&
296+
transform->transform()->transform_type() != TransformType::kIdentity) {
297+
// truncate must be rewritten in binding. the result is either always or never
298+
// compatible
299+
return kRowsMightMatch;
300+
}
301301

302302
int32_t id = expr->reference()->field().field_id();
303303
if (ContainsNullsOnly(id)) {
@@ -410,10 +410,10 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
410410
}
411411

412412
Result<std::optional<Literal>> LowerBound(const std::shared_ptr<Bound>& expr) {
413-
if (auto reference = internal::checked_pointer_cast<BoundReference>(expr);
413+
if (auto reference = std::dynamic_pointer_cast<BoundReference>(expr);
414414
reference != nullptr) {
415415
return ParseLowerBound(*reference);
416-
} else if (auto transform = internal::checked_pointer_cast<BoundTransform>(expr);
416+
} else if (auto transform = std::dynamic_pointer_cast<BoundTransform>(expr);
417417
transform != nullptr) {
418418
return TransformLowerBound(*transform);
419419
} else {
@@ -423,10 +423,10 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
423423
}
424424

425425
Result<std::optional<Literal>> UpperBound(const std::shared_ptr<Bound>& expr) {
426-
if (auto reference = internal::checked_pointer_cast<BoundReference>(expr);
426+
if (auto reference = std::dynamic_pointer_cast<BoundReference>(expr);
427427
reference != nullptr) {
428428
return ParseUpperBound(*reference);
429-
} else if (auto transform = internal::checked_pointer_cast<BoundTransform>(expr);
429+
} else if (auto transform = std::dynamic_pointer_cast<BoundTransform>(expr);
430430
transform != nullptr) {
431431
return TransformUpperBound(*transform);
432432
} else {
@@ -439,7 +439,7 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
439439
int32_t id = ref.field().field_id();
440440
auto type = ref.type();
441441
if (!type->is_primitive()) {
442-
return Invalid("Lower bound of non-primitive type is not supported.");
442+
return NotSupported("Lower bound of non-primitive type is not supported.");
443443
}
444444
auto primitive_type = internal::checked_pointer_cast<PrimitiveType>(type);
445445
if (!data_file_.lower_bounds.empty() && data_file_.lower_bounds.contains(id)) {
@@ -456,7 +456,7 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
456456
int32_t id = ref.field().field_id();
457457
auto type = ref.type();
458458
if (!type->is_primitive()) {
459-
return Invalid("Upper bound of non-primitive type is not supported.");
459+
return NotSupported("Upper bound of non-primitive type is not supported.");
460460
}
461461
auto primitive_type = internal::checked_pointer_cast<PrimitiveType>(type);
462462
if (!data_file_.upper_bounds.empty() && data_file_.upper_bounds.contains(id)) {
@@ -499,10 +499,10 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
499499

500500
/** Returns true if the expression term produces a non-null value for non-null input. */
501501
bool IsNonNullPreserving(const std::shared_ptr<Bound>& expr) {
502-
if (auto reference = internal::checked_pointer_cast<BoundReference>(expr);
502+
if (auto reference = std::dynamic_pointer_cast<BoundReference>(expr);
503503
reference != nullptr) {
504504
return true;
505-
} else if (auto transform = internal::checked_pointer_cast<BoundTransform>(expr);
505+
} else if (auto transform = std::dynamic_pointer_cast<BoundTransform>(expr);
506506
transform != nullptr) {
507507
return transform->transform()->PreservesOrder();
508508
}

0 commit comments

Comments
 (0)