paleolimbot commented on code in PR #81:
URL: https://github.com/apache/arrow-nanoarrow/pull/81#discussion_r1041055778
##########
src/nanoarrow/schema.c:
##########
@@ -281,27 +301,67 @@ ArrowErrorCode ArrowSchemaInitDateTime(struct
ArrowSchema* schema,
break;
case NANOARROW_TYPE_DURATION:
if (timezone != NULL) {
- schema->release(schema);
return EINVAL;
}
n_chars = snprintf(buffer, sizeof(buffer), "tD%s", time_unit_str);
break;
default:
- schema->release(schema);
return EINVAL;
}
if (((size_t)n_chars) >= sizeof(buffer)) {
- schema->release(schema);
return ERANGE;
}
buffer[n_chars] = '\0';
- result = ArrowSchemaSetFormat(schema, buffer);
- if (result != NANOARROW_OK) {
- schema->release(schema);
- return result;
+ return ArrowSchemaSetFormat(schema, buffer);
+}
+
+ArrowErrorCode ArrowSchemaSetTypeUnion(struct ArrowSchema* schema,
+ enum ArrowType data_type, int64_t
n_children) {
+ if (n_children < 1 || n_children > 127) {
Review Comment:
The zero-case union is apparently not supported by Arrow C++'s C Data
interface. I get:
```
'arrow_type' failed with Invalid: Invalid or unsupported format string:
'+us:'
```
Reproducer for Python:
```python
import pyarrow as pa
from pyarrow.cffi import ffi
empty_union = pa.sparse_union([])
ptr = ffi.new("struct ArrowSchema*")
empty_union._export_to_c(int(ffi.cast("uintptr_t", ptr)))
pa.DataType._import_from_c(int(ffi.cast("uintptr_t", ptr)))
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# File "pyarrow/types.pxi", line 248, in
pyarrow.lib.DataType._import_from_c
# File "pyarrow/error.pxi", line 144, in
pyarrow.lib.pyarrow_internal_check_status
# File "pyarrow/error.pxi", line 100, in pyarrow.lib.check_status
# pyarrow.lib.ArrowInvalid: Invalid or unsupported format string: '+us:'
```
--
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]