@@ -83,6 +83,8 @@ StatusOr<TransformResult> GeoPredicateIndexScanBaseRule::transform(
83
83
return TransformResult::noTransform ();
84
84
}
85
85
86
+ const std::string& geoProp = static_cast <PropertyExpression*>(first)->prop ();
87
+
86
88
if (!graph::ExpressionUtils::isEvaluableExpr (second, qctx)) {
87
89
return TransformResult::noTransform ();
88
90
}
@@ -94,18 +96,33 @@ StatusOr<TransformResult> GeoPredicateIndexScanBaseRule::transform(
94
96
95
97
const auto & geog = secondVal.getGeography ();
96
98
97
- auto indexItem = indexItems.back ();
98
- const auto & fields = indexItem->get_fields ();
99
- if (fields.size () != 1 ) {
99
+ std::shared_ptr<nebula::meta::cpp2::IndexItem> geoIndexItem = nullptr ;
100
+ for (auto & indexItem : indexItems) {
101
+ auto & fields = indexItem->get_fields ();
102
+ if (fields.size () != 1 ) {
103
+ continue ;
104
+ }
105
+ if (fields[0 ].get_type ().get_type () != nebula::cpp2::PropertyType::GEOGRAPHY) {
106
+ continue ;
107
+ }
108
+ if (fields[0 ].get_name () != geoProp) {
109
+ continue ;
110
+ }
111
+ geoIndexItem = indexItem;
112
+ break ;
113
+ }
114
+ if (!geoIndexItem) {
100
115
return TransformResult::noTransform ();
101
116
}
117
+ const auto & fields = geoIndexItem->get_fields ();
118
+ DCHECK_EQ (fields.size (), 1 );
102
119
auto & geoField = fields.back ();
103
120
auto & geoColumnTypeDef = geoField.get_type ();
104
121
bool isPointColumn = geoColumnTypeDef.geo_shape_ref ().has_value () &&
105
122
geoColumnTypeDef.geo_shape_ref ().value () == meta::cpp2::GeoShape::POINT;
106
123
107
124
geo::RegionCoverParams rc;
108
- const auto * indexParams = indexItem ->get_index_params ();
125
+ const auto * indexParams = geoIndexItem ->get_index_params ();
109
126
if (indexParams) {
110
127
if (indexParams->s2_max_level_ref ().has_value ()) {
111
128
rc.maxCellLevel_ = indexParams->s2_max_level_ref ().value ();
@@ -145,7 +162,7 @@ StatusOr<TransformResult> GeoPredicateIndexScanBaseRule::transform(
145
162
auto indexColumnHint = scanRange.toIndexColumnHint ();
146
163
indexColumnHint.column_name_ref () = fieldName;
147
164
ictx.filter_ref () = condition->encode ();
148
- ictx.index_id_ref () = indexItem ->get_index_id ();
165
+ ictx.index_id_ref () = geoIndexItem ->get_index_id ();
149
166
ictx.column_hints_ref () = {indexColumnHint};
150
167
idxCtxs.emplace_back (std::move (ictx));
151
168
}
0 commit comments