linrrzqqq commented on code in PR #63049:
URL: https://github.com/apache/doris/pull/63049#discussion_r3296708340


##########
be/src/exprs/function/geo/functions_geo.cpp:
##########
@@ -917,6 +919,174 @@ struct StDistance {
     }
 };
 
+struct StNumGeometries {
+    static constexpr auto NAME = "st_numgeometries";
+    static const size_t NUM_ARGS = 1;
+    using Type = DataTypeInt64;
+
+    static Status execute(Block& block, const ColumnNumbers& arguments, size_t 
result) {
+        DCHECK_EQ(arguments.size(), 1);
+
+        auto col = 
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+        const auto size = col->size();
+
+        auto res = ColumnInt64::create();
+        res->reserve(size);
+
+        auto null_map = ColumnUInt8::create(size, 0);
+        auto& null_map_data = null_map->get_data();
+
+        for (int row = 0; row < size; ++row) {
+            auto value = col->get_data_at(row);
+            auto shape = GeoShape::from_encoded(value.data, value.size);
+            if (!shape) {
+                null_map_data[row] = 1;
+                res->insert_default();
+                continue;
+            }
+
+            res->insert_value(shape->num_geometries());
+        }
+
+        block.replace_by_position(result,
+                                  ColumnNullable::create(std::move(res), 
std::move(null_map)));
+        return Status::OK();
+    }
+};
+
+struct StGeometries {
+    static constexpr auto NAME = "st_geometries";
+    static const size_t NUM_ARGS = 1;
+
+    static Status execute(Block& block, const ColumnNumbers& arguments, size_t 
result) {
+        DCHECK_EQ(arguments.size(), 1);
+
+        auto col = 
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();

Review Comment:
   ditto, use `ColumnView`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to