-
ContextWe have an Arrow Flight SQL server and noticed that when users call Observed Behavior
cursor.adbc_prepare("INSERT INTO my_table(col) VALUES (?)")
param_schema = cursor._stmt.get_parameter_schema()
# Returns: Schema([Field('$1', int32)])
cursor.executemany("INSERT INTO my_table(col) VALUES (?)", [(1,), (2,), (3,)])
WorkaroundUsers can manually create Arrow data with correct types: cursor.adbc_prepare("INSERT INTO my_table(col) VALUES (?)")
param_schema = pa.Schema._import_from_c_capsule(
cursor._stmt.get_parameter_schema().__arrow_c_schema__()
)
batch = pa.record_batch([[1, 2, 3]], schema=param_schema)
cursor.executemany("INSERT INTO my_table(col) VALUES (?)", batch)
# Works!QuestionIs this behavior by design? Looking at the code, Should ADBC:
If (1) is intentional, it might be worth documenting this more explicitly. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
I think (1) is the only realistic answer for the spec as a whole, though individual drivers might be able to do (2) under some circumstances. |
Beta Was this translation helpful? Give feedback.
Right, the conversion from Python values to Arrow is best-effort. While we could use the schema from GetParameterSchema instead, I'm hesitant since I think for many systems, the schema is not fully reflective of the actual types (e.g. I know Postgres will give VARCHAR when the type is ambiguous/multiple types are possible)