@@ -75,6 +75,8 @@ pub enum FileFormatParams {
7575 Orc ( OrcFileFormatParams ) ,
7676 Avro ( AvroFileFormatParams ) ,
7777 Lance ( LanceFileFormatParams ) ,
78+ Arrow ( ArrowFileFormatParams ) ,
79+ ArrowStream ( ArrowFileFormatParams ) ,
7880}
7981
8082impl FileFormatParams {
@@ -89,6 +91,8 @@ impl FileFormatParams {
8991 FileFormatParams :: Orc ( _) => StageFileFormatType :: Orc ,
9092 FileFormatParams :: Avro ( _) => StageFileFormatType :: Avro ,
9193 FileFormatParams :: Lance ( _) => StageFileFormatType :: Lance ,
94+ FileFormatParams :: Arrow ( _) => StageFileFormatType :: Arrow ,
95+ FileFormatParams :: ArrowStream ( _) => StageFileFormatType :: ArrowStream ,
9296 }
9397 }
9498
@@ -103,6 +107,8 @@ impl FileFormatParams {
103107 FileFormatParams :: Orc ( _) => ".orc" ,
104108 FileFormatParams :: Avro ( _) => ".avro" ,
105109 FileFormatParams :: Lance ( _) => ".lance" ,
110+ FileFormatParams :: Arrow ( _) => ".arrow" ,
111+ FileFormatParams :: ArrowStream ( _) => ".arrow_stream" ,
106112 }
107113 }
108114
@@ -113,6 +119,8 @@ impl FileFormatParams {
113119 | FileFormatParams :: Text ( _)
114120 | FileFormatParams :: NdJson ( _)
115121 | FileFormatParams :: Parquet ( _)
122+ | FileFormatParams :: Arrow ( _)
123+ | FileFormatParams :: ArrowStream ( _)
116124 )
117125 }
118126
@@ -138,6 +146,12 @@ impl FileFormatParams {
138146 StageFileFormatType :: Lance => {
139147 Ok ( FileFormatParams :: Lance ( LanceFileFormatParams :: default ( ) ) )
140148 }
149+ StageFileFormatType :: Arrow => {
150+ Ok ( FileFormatParams :: Arrow ( ArrowFileFormatParams :: default ( ) ) )
151+ }
152+ StageFileFormatType :: ArrowStream => Ok ( FileFormatParams :: ArrowStream (
153+ ArrowFileFormatParams :: default ( ) ,
154+ ) ) ,
141155 _ => Err ( ErrorCode :: IllegalFileFormat ( format ! (
142156 "Unsupported file format type: {:?}" ,
143157 format_type
@@ -156,6 +170,9 @@ impl FileFormatParams {
156170 FileFormatParams :: Orc ( _) => StageFileCompression :: None ,
157171 FileFormatParams :: Avro ( _) => StageFileCompression :: None ,
158172 FileFormatParams :: Lance ( _) => StageFileCompression :: None ,
173+ FileFormatParams :: Arrow ( _) | FileFormatParams :: ArrowStream ( _) => {
174+ StageFileCompression :: None
175+ }
159176 }
160177 }
161178
@@ -190,6 +207,9 @@ impl FileFormatParams {
190207 v. null_field_as == NullAs :: FieldDefault
191208 || v. missing_field_as == NullAs :: FieldDefault
192209 }
210+ FileFormatParams :: Arrow ( v) | FileFormatParams :: ArrowStream ( v) => {
211+ v. missing_field_as == NullAs :: FieldDefault
212+ }
193213 _ => true ,
194214 }
195215 }
@@ -253,6 +273,18 @@ impl FileFormatParams {
253273 ) ?)
254274 }
255275 StageFileFormatType :: Lance => FileFormatParams :: Lance ( LanceFileFormatParams :: default ( ) ) ,
276+ StageFileFormatType :: Arrow => {
277+ let missing_field_as = reader. options . remove ( MISSING_FIELD_AS ) ;
278+ FileFormatParams :: Arrow ( ArrowFileFormatParams :: try_create (
279+ missing_field_as. as_deref ( ) ,
280+ ) ?)
281+ }
282+ StageFileFormatType :: ArrowStream => {
283+ let missing_field_as = reader. options . remove ( MISSING_FIELD_AS ) ;
284+ FileFormatParams :: ArrowStream ( ArrowFileFormatParams :: try_create (
285+ missing_field_as. as_deref ( ) ,
286+ ) ?)
287+ }
256288 StageFileFormatType :: Csv => {
257289 let default = CsvFileFormatParams :: default ( ) ;
258290 let compression = reader. take_compression_default_none ( ) ?;
@@ -1027,6 +1059,18 @@ impl OrcFileFormatParams {
10271059#[ derive( Clone , Debug , Default , PartialEq , Eq , Serialize , Deserialize ) ]
10281060pub struct LanceFileFormatParams { }
10291061
1062+ #[ derive( Clone , Debug , Default , PartialEq , Eq , Serialize , Deserialize ) ]
1063+ pub struct ArrowFileFormatParams {
1064+ pub missing_field_as : NullAs ,
1065+ }
1066+
1067+ impl ArrowFileFormatParams {
1068+ pub fn try_create ( missing_field_as : Option < & str > ) -> Result < Self > {
1069+ let missing_field_as = NullAs :: parse ( missing_field_as, MISSING_FIELD_AS , NullAs :: Error ) ?;
1070+ Ok ( Self { missing_field_as } )
1071+ }
1072+ }
1073+
10301074impl Display for FileFormatParams {
10311075 fn fmt ( & self , f : & mut Formatter ) -> std:: fmt:: Result {
10321076 match self {
@@ -1118,6 +1162,20 @@ impl Display for FileFormatParams {
11181162 FileFormatParams :: Lance ( _) => {
11191163 write ! ( f, "TYPE = LANCE" )
11201164 }
1165+ FileFormatParams :: Arrow ( params) => {
1166+ write ! (
1167+ f,
1168+ "TYPE = ARROW MISSING_FIELD_AS = {}" ,
1169+ params. missing_field_as
1170+ )
1171+ }
1172+ FileFormatParams :: ArrowStream ( params) => {
1173+ write ! (
1174+ f,
1175+ "TYPE = ARROW_STREAM MISSING_FIELD_AS = {}" ,
1176+ params. missing_field_as
1177+ )
1178+ }
11211179 }
11221180 }
11231181}
0 commit comments