15
15
// specific language governing permissions and limitations
16
16
// under the License.
17
17
18
- use std:: { ops :: Deref , sync:: Arc } ;
18
+ use std:: sync:: Arc ;
19
19
20
- use arrow_schema:: { DataType , Field , Fields , IntervalUnit , TimeUnit , UnionFields } ;
20
+ use arrow_schema:: { DataType , IntervalUnit , TimeUnit } ;
21
21
22
- use super :: { LogicalType , TypeSignature } ;
23
-
24
- /// A record of a native type, its name and its nullability.
25
- #[ derive( Debug , Clone , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
26
- pub struct NativeField {
27
- name : String ,
28
- native_type : NativeType ,
29
- nullable : bool ,
30
- }
31
-
32
- impl NativeField {
33
- pub fn name ( & self ) -> & str {
34
- & self . name
35
- }
36
-
37
- pub fn native_type ( & self ) -> & NativeType {
38
- & self . native_type
39
- }
40
-
41
- pub fn nullable ( & self ) -> bool {
42
- self . nullable
43
- }
44
- }
45
-
46
- /// A reference counted [`NativeField`].
47
- pub type NativeFieldRef = Arc < NativeField > ;
48
-
49
- /// A cheaply cloneable, owned collection of [`NativeFieldRef`].
50
- #[ derive( Debug , Clone , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
51
- pub struct NativeFields ( Arc < [ NativeFieldRef ] > ) ;
52
-
53
- impl Deref for NativeFields {
54
- type Target = [ NativeFieldRef ] ;
55
-
56
- fn deref ( & self ) -> & Self :: Target {
57
- self . 0 . as_ref ( )
58
- }
59
- }
60
-
61
- /// A cheaply cloneable, owned collection of [`NativeFieldRef`] and their
62
- /// corresponding type ids.
63
- #[ derive( Debug , Clone , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
64
- pub struct NativeUnionFields ( Arc < [ ( i8 , NativeFieldRef ) ] > ) ;
65
-
66
- impl Deref for NativeUnionFields {
67
- type Target = [ ( i8 , NativeFieldRef ) ] ;
68
-
69
- fn deref ( & self ) -> & Self :: Target {
70
- self . 0 . as_ref ( )
71
- }
72
- }
22
+ use super :: {
23
+ LogicalFieldRef , LogicalFields , LogicalType , LogicalUnionFields , TypeSignature ,
24
+ } ;
73
25
74
26
/// Representation of a type that DataFusion can handle natively. It is a subset
75
27
/// of the physical variants in Arrow's native [`DataType`].
@@ -196,13 +148,13 @@ pub enum NativeType {
196
148
/// A variable-length string in Unicode with UTF-8 encoding.
197
149
Utf8 ,
198
150
/// A list of some logical data type with variable length.
199
- List ( NativeFieldRef ) ,
151
+ List ( LogicalFieldRef ) ,
200
152
/// A list of some logical data type with fixed length.
201
- FixedSizeList ( NativeFieldRef , i32 ) ,
153
+ FixedSizeList ( LogicalFieldRef , i32 ) ,
202
154
/// A nested type that contains a number of sub-fields.
203
- Struct ( NativeFields ) ,
155
+ Struct ( LogicalFields ) ,
204
156
/// A nested type that can represent slots of differing types.
205
- Union ( NativeUnionFields ) ,
157
+ Union ( LogicalUnionFields ) ,
206
158
/// Decimal value with precision and scale
207
159
///
208
160
/// * precision is the total number of digits
@@ -222,11 +174,10 @@ pub enum NativeType {
222
174
/// The key and value types are not constrained, but keys should be
223
175
/// hashable and unique.
224
176
///
225
- /// In a field with Map type, the field has a child Struct field, which then
226
- /// has two children: key type and the second the value type. The names of the
177
+ /// In a field with Map type, key type and the second the value type. The names of the
227
178
/// child fields may be respectively "entries", "key", and "value", but this is
228
179
/// not enforced.
229
- Map ( NativeFieldRef ) ,
180
+ Map ( LogicalFieldRef ) ,
230
181
}
231
182
232
183
impl LogicalType for NativeType {
@@ -275,9 +226,9 @@ impl From<DataType> for NativeType {
275
226
DataType :: FixedSizeList ( field, size) => {
276
227
FixedSizeList ( Arc :: new ( field. as_ref ( ) . into ( ) ) , size)
277
228
}
278
- DataType :: Struct ( fields) => Struct ( NativeFields :: from ( & fields) ) ,
229
+ DataType :: Struct ( fields) => Struct ( LogicalFields :: from ( & fields) ) ,
279
230
DataType :: Union ( union_fields, _) => {
280
- Union ( NativeUnionFields :: from ( & union_fields) )
231
+ Union ( LogicalUnionFields :: from ( & union_fields) )
281
232
}
282
233
DataType :: Dictionary ( _, data_type) => data_type. as_ref ( ) . clone ( ) . into ( ) ,
283
234
DataType :: Decimal128 ( p, s) | DataType :: Decimal256 ( p, s) => Decimal ( p, s) ,
@@ -286,43 +237,3 @@ impl From<DataType> for NativeType {
286
237
}
287
238
}
288
239
}
289
-
290
- impl From < & Field > for NativeField {
291
- fn from ( value : & Field ) -> Self {
292
- Self {
293
- name : value. name ( ) . clone ( ) ,
294
- native_type : value. data_type ( ) . clone ( ) . into ( ) ,
295
- nullable : value. is_nullable ( ) ,
296
- }
297
- }
298
- }
299
-
300
- impl From < & Fields > for NativeFields {
301
- fn from ( value : & Fields ) -> Self {
302
- value
303
- . iter ( )
304
- . map ( |field| Arc :: new ( NativeField :: from ( field. as_ref ( ) ) ) )
305
- . collect ( )
306
- }
307
- }
308
-
309
- impl FromIterator < NativeFieldRef > for NativeFields {
310
- fn from_iter < T : IntoIterator < Item = NativeFieldRef > > ( iter : T ) -> Self {
311
- Self ( iter. into_iter ( ) . collect ( ) )
312
- }
313
- }
314
-
315
- impl From < & UnionFields > for NativeUnionFields {
316
- fn from ( value : & UnionFields ) -> Self {
317
- value
318
- . iter ( )
319
- . map ( |( i, field) | ( i, Arc :: new ( NativeField :: from ( field. as_ref ( ) ) ) ) )
320
- . collect ( )
321
- }
322
- }
323
-
324
- impl FromIterator < ( i8 , NativeFieldRef ) > for NativeUnionFields {
325
- fn from_iter < T : IntoIterator < Item = ( i8 , NativeFieldRef ) > > ( iter : T ) -> Self {
326
- Self ( iter. into_iter ( ) . collect ( ) )
327
- }
328
- }
0 commit comments