hello-stephen commented on code in PR #71342:
URL: https://github.com/apache/doris/pull/71342#discussion_r4790273027


##########
fe/fe-core/src/main/java/org/apache/doris/arrowflight/FlightSqlSchemaHelper.java:
##########
@@ -281,8 +282,26 @@ private Map<String, List<Field>> buildTableToFields(String 
dbName, TDescribeTabl
         return tableToFields;
     }
 
-    private static Field buildField(String dbName, String tableName, 
TColumnDesc desc) {
-        return withNativeVariant(DorisArrowTypeMapping.toField(dbName, 
tableName, desc), desc);
+    static Field buildField(String dbName, String tableName, TColumnDesc desc) 
{
+        Field field = DorisArrowTypeMapping.toField(dbName, tableName, desc);
+        return geoArrowField(field.getName(), field.isNullable(), 
desc.getColumnType(), desc.getSpatialCrs(),

Review Comment:
   [P2] Use read nullability for GeoArrow table schemas. Iceberg imports even 
required fields as read-nullable because schema evolution can produce NULL. 
`describeTables` takes its columns from the display schema, where the same 
field is non-nullable. This makes `GetTables(include_schema=true)` advertise a 
non-nullable GeoArrow field while `GetSchema` and `DoGet` use a nullable one. 
Pass the read nullability to the GeoArrow mapping and cover a required Iceberg 
spatial field in the parity test.



##########
be/src/format/arrow/arrow_block_convertor.cpp:
##########
@@ -464,6 +493,19 @@ Status ArrowFlightArrowBlockConvertor::write_column(const 
std::shared_ptr<const
                                                     arrow::ArrayBuilder* 
array_builder,
                                                     int64_t start, int64_t end,
                                                     const cctz::time_zone& 
ctz) const {
+    const auto kind = type->get_primitive_type();
+    if (kind == TYPE_GEOMETRY || kind == TYPE_GEOGRAPHY) {
+        std::shared_ptr<arrow::Field> expected;
+        RETURN_IF_ERROR(
+                FlightSqlResultSchemaConvertor(ctz.name())
+                        .make_result_field(field->name(), type, 
field->nullable(), &expected));
+        if (!field->Equals(*expected, /*check_metadata=*/true)) {
+            return Status::InvalidArgument("Expected a GeoArrow WKB field for 
{}",
+                                           type->get_name());
+        }
+        RETURN_IF_ERROR(validate_geoarrow_wkb_capacity(column, null_map, 
start, end, *field));
+        return serde.write_column_to_arrow(column, null_map, array_builder, 
start, end, ctz);

Review Comment:
   [P2] Track the Arrow buffers allocated for GeoArrow WKB. This SerDe copies 
WKB into the Binary builder while the input block is still live. Both Flight 
readers pass `arrow::default_memory_pool()`, so a batch with hundreds of MiB of 
WKB can make a second allocation of that scale outside Doris memory accounting 
even when it fits the byte limit. Charge those buffers to the result tracker 
and keep the accounting associated with them until the Flight stream releases 
them.



##########
samples/arrow-flight-sql/python/README.md:
##########
@@ -62,6 +62,18 @@ The tests execute only read-only queries.
      For more details, refer to [Python Usage] in the document 
https://doris.apache.org/zh-CN/docs/dev/db-connect/arrow-flight-sql-connect
 
 
+## Spatial results
+
+Selecting a default top-level `GEOMETRY` or `GEOGRAPHY` column returns

Review Comment:
   [P3] Document the BE upgrade requirement for proxied Flight. An upgraded 
result BE can advertise GeoArrow in `FlightInfo` while the public proxy routes 
`DoGet` to an older BE. That node fetches and converts the block itself, so it 
rejects the spatial type. State that direct GeoArrow output requires support on 
the result BE and every BE that can serve its `DoGet`, and point to 
`ST_AsBinary` during the rollout.



-- 
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