pitrou commented on code in PR #48727:
URL: https://github.com/apache/arrow/pull/48727#discussion_r2853142462


##########
python/pyarrow/src/arrow/python/python_to_arrow.cc:
##########
@@ -1268,16 +1274,24 @@ Result<std::shared_ptr<ChunkedArray>> 
ConvertPySequence(PyObject* obj, PyObject*
   // In some cases, type inference may be "loose", like strings. If the user
   // passed pa.string(), then we will error if we encounter any non-UTF8
   // value. If not, then we will allow the result to be a BinaryArray
+  std::shared_ptr<DataType> extension_type;
   if (options.type == nullptr) {
     ARROW_ASSIGN_OR_RAISE(options.type, InferArrowType(seq, mask, 
options.from_pandas));
     options.strict = false;
+    // If type inference returned an extension type, convert using
+    // the storage type and then wrap the result as an extension array
+    if (options.type->id() == Type::EXTENSION) {
+      extension_type = options.type;
+      options.type = checked_cast<const 
ExtensionType&>(*options.type).storage_type();
+    }
   } else {
     options.strict = true;
   }
   ARROW_DCHECK_GE(size, 0);
 
   ARROW_ASSIGN_OR_RAISE(auto converter, (MakeConverter<PyConverter, 
PyConverterTrait>(
                                             options.type, options, pool)));

Review Comment:
   Does `MakeConverter` support extension types here? I see that we only unwrap 
the extension type in the inference path above.



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

Reply via email to