@@ -120,7 +120,7 @@ Value TransformDictionaryToStruct(optional_ptr<ClientContext> context, const PyD
120120 const LogicalType &target_type = LogicalType::UNKNOWN ) {
121121 auto struct_keys = TransformStructKeys (dict.keys , dict.len , target_type);
122122
123- bool struct_target = target_type.id () == LogicalTypeId::STRUCT ;
123+ bool struct_target = target_type.id () == LogicalTypeId::STRUCT || target_type. id () == LogicalTypeId:: TUPLE ;
124124 if (struct_target && dict.len != StructType::GetChildCount (target_type)) {
125125 throw InvalidInputException (" We could not convert the object %s to the desired target type (%s)" ,
126126 dict.ToString (), target_type.ToString ());
@@ -255,7 +255,7 @@ Value TransformTupleToStruct(optional_ptr<ClientContext> context, nb::handle ele
255255 auto tuple = nb::cast<nb::tuple>(ele);
256256 auto size = nb::len (tuple);
257257
258- D_ASSERT (target_type.id () == LogicalTypeId::STRUCT );
258+ D_ASSERT (target_type.id () == LogicalTypeId::STRUCT || target_type. id () == LogicalTypeId:: TUPLE );
259259 auto child_types = StructType::GetChildTypes (target_type);
260260 auto child_count = child_types.size ();
261261 if (size != child_count) {
@@ -562,7 +562,7 @@ struct PythonValueConversion {
562562
563563 static void HandleTuple (optional_ptr<ClientContext> context, Value &result, const LogicalType &target_type,
564564 nb::handle ele, idx_t list_size) {
565- if (target_type.id () == LogicalTypeId::STRUCT ) {
565+ if (target_type.id () == LogicalTypeId::STRUCT || target_type. id () == LogicalTypeId:: TUPLE ) {
566566 result = TransformTupleToStruct (context, ele, target_type);
567567 return ;
568568 }
@@ -588,6 +588,7 @@ struct PythonValueConversion {
588588 PyDictionary dict = PyDictionary (nb::borrow<nb::object>(ele));
589589 switch (target_type.id ()) {
590590 case LogicalTypeId::STRUCT :
591+ case LogicalTypeId::TUPLE :
591592 return TransformDictionaryToStruct (context, dict, target_type);
592593 case LogicalTypeId::MAP :
593594 return TransformDictionaryToMap (context, dict, target_type);
@@ -890,6 +891,7 @@ struct PythonVectorConversion {
890891 auto &result_type = result.GetType ();
891892 switch (result_type.id ()) {
892893 case LogicalTypeId::STRUCT :
894+ case LogicalTypeId::TUPLE :
893895 ConvertTupleToStruct (context, result, result_offset, ele, tuple_size);
894896 break ;
895897 case LogicalTypeId::ARRAY :
@@ -985,6 +987,7 @@ void TransformPythonObjectInternal(optional_ptr<ClientContext> context, nb::hand
985987 auto &conversion_target = OP::ConversionTarget (result, param);
986988 switch (conversion_target.id ()) {
987989 case LogicalTypeId::STRUCT :
990+ case LogicalTypeId::TUPLE :
988991 case LogicalTypeId::UNKNOWN :
989992 case LogicalTypeId::LIST :
990993 case LogicalTypeId::ARRAY :
0 commit comments