hello-stephen commented on code in PR #71342:
URL: https://github.com/apache/doris/pull/71342#discussion_r4781618627
##########
fe/fe-core/src/main/java/org/apache/doris/arrowflight/FlightSqlQuerySchema.java:
##########
@@ -402,6 +402,20 @@ private static void resolveNamespace(ConnectContext
context, Plan plan, Map<Stri
*/
private static Field field(String name, Type type, boolean nullable,
String timezone)
throws UndiscoverableSchemaException {
+ // Only top-level default spatial columns have a GeoArrow wire
representation.
+ if (type instanceof ScalarType && ((ScalarType) type).isSpatialType())
{
+ ScalarType spatial = (ScalarType) type;
+ boolean geography = spatial.getPrimitiveType() ==
PrimitiveType.GEOGRAPHY;
+ if (!"OGC:CRS84".equals(spatial.getSpatialCrs())
+ || (geography &&
!"spherical".equals(spatial.getSpatialAlgorithm()))) {
+ throw new UndiscoverableSchemaException("Unsupported Arrow
result type: " + type);
+ }
+ String metadata = geography
+ ?
"{\"crs\":\"OGC:CRS84\",\"crs_type\":\"authority_code\",\"edges\":\"spherical\"}"
+ :
"{\"crs\":\"OGC:CRS84\",\"crs_type\":\"authority_code\"}";
+ return new Field(name, new FieldType(nullable, new
ArrowType.Binary(), null,
Review Comment:
[P2] Keep Flight SQL table-schema discovery consistent with the new spatial
result schema. A default GEOMETRY/GEOGRAPHY column of an Iceberg table now
returns Binary with geoarrow.wkb metadata from SELECT, but
GetTables(include_schema=true) still goes through
FlightSqlSchemaHelper.buildField and DorisArrowTypeMapping.toField, which falls
through to Arrow Null for both spatial types. DorisArrowTypeMappingTest
explicitly pins Null because direct spatial results were previously
unsupported. Clients that use table_schema to type result columns therefore get
an incompatible schema for a newly supported column. Please update the parallel
metadata path and its tests, preserving the actual CRS/algorithm (TColumnDesc
currently lacks them) so unsupported non-default or nested spatial types are
not incorrectly advertised as supported.
##########
be/src/format/arrow/arrow_block_convertor.cpp:
##########
@@ -534,6 +546,19 @@ Status ArrowBlockConvertor::convert_from_arrow(const
std::shared_ptr<arrow::Reco
return Status::NotSupported("This Arrow converter does not support
reading");
}
+std::shared_ptr<arrow::DataType> binary_builder_type(const arrow::Field& field,
+ size_t column_bytes) {
+ if (column_bytes < MAX_ARROW_UTF8) {
+ return field.type();
+ }
+ // Flight SQL publishes geoarrow.wkb with 32-bit offsets for the entire
stream.
+ const auto& metadata = field.metadata();
+ if (metadata && metadata->Get("ARROW:extension:name").ValueOr("") ==
"geoarrow.wkb") {
+ return field.type();
Review Comment:
[P2] Bound GeoArrow batches to the published 32-bit offset capacity. Keeping
Binary rather than LargeBinary is necessary for a stable Flight schema, but
ArrowFlightBatchLocalReader::ReadNextImpl passes an entire result block to
convert_to_arrow, and ResultBlockBuffer::add_batch only caps concatenation with
the previous block, not the size of a standalone block. FileScannerV2's
adaptive batch size is an estimate, not a hard payload limit. Thus a valid
result block with aggregate non-null WKB beyond Binary's offset capacity can
fail in BinaryBuilder::Append even when every individual geometry fits and
could be streamed in smaller batches. This local-reader path does not have the
remote protobuf size limit. Partition the rows before writing each GeoArrow
RecordBatch, or explicitly define the aggregate-size restriction and cover the
error boundary. The new size-selector test checks the type choice only, not the
conversion of a batch at the offset limit.
--
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]