File tree 1 file changed +9
-7
lines changed 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -810,9 +810,16 @@ impl From<&DFSchema> for Schema {
810
810
impl TryFrom < Schema > for DFSchema {
811
811
type Error = DataFusionError ;
812
812
fn try_from ( schema : Schema ) -> Result < Self , Self :: Error > {
813
+ Self :: try_from ( Arc :: new ( schema) )
814
+ }
815
+ }
816
+
817
+ impl TryFrom < SchemaRef > for DFSchema {
818
+ type Error = DataFusionError ;
819
+ fn try_from ( schema : SchemaRef ) -> Result < Self , Self :: Error > {
813
820
let field_count = schema. fields . len ( ) ;
814
821
let dfschema = Self {
815
- inner : schema. into ( ) ,
822
+ inner : schema,
816
823
field_qualifiers : vec ! [ None ; field_count] ,
817
824
functional_dependencies : FunctionalDependencies :: empty ( ) ,
818
825
} ;
@@ -856,12 +863,7 @@ impl ToDFSchema for Schema {
856
863
857
864
impl ToDFSchema for SchemaRef {
858
865
fn to_dfschema ( self ) -> Result < DFSchema > {
859
- // Attempt to use the Schema directly if there are no other
860
- // references, otherwise clone
861
- match Self :: try_unwrap ( self ) {
862
- Ok ( schema) => DFSchema :: try_from ( schema) ,
863
- Err ( schemaref) => DFSchema :: try_from ( schemaref. as_ref ( ) . clone ( ) ) ,
864
- }
866
+ DFSchema :: try_from ( self )
865
867
}
866
868
}
867
869
You can’t perform that action at this time.
0 commit comments