@@ -3347,6 +3347,22 @@ pub enum Statement {
3347
3347
channel : Ident ,
3348
3348
payload : Option < String > ,
3349
3349
} ,
3350
+ /// ```sql
3351
+ /// LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename
3352
+ /// [PARTITION (partcol1=val1, partcol2=val2 ...)]
3353
+ /// [INPUTFORMAT 'inputformat' SERDE 'serde']
3354
+ /// ```
3355
+ /// Loading files into tables
3356
+ ///
3357
+ /// See Hive <https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=27362036#LanguageManualDML-Loadingfilesintotables>
3358
+ LoadData {
3359
+ local : bool ,
3360
+ inpath : String ,
3361
+ overwrite : bool ,
3362
+ table_name : ObjectName ,
3363
+ partitioned : Option < Vec < Expr > > ,
3364
+ table_format : Option < HiveLoadDataFormat > ,
3365
+ } ,
3350
3366
}
3351
3367
3352
3368
impl fmt:: Display for Statement {
@@ -3949,6 +3965,36 @@ impl fmt::Display for Statement {
3949
3965
Ok ( ( ) )
3950
3966
}
3951
3967
Statement :: CreateTable ( create_table) => create_table. fmt ( f) ,
3968
+ Statement :: LoadData {
3969
+ local,
3970
+ inpath,
3971
+ overwrite,
3972
+ table_name,
3973
+ partitioned,
3974
+ table_format,
3975
+ } => {
3976
+ write ! (
3977
+ f,
3978
+ "LOAD DATA {local}INPATH '{inpath}' {overwrite}INTO TABLE {table_name}" ,
3979
+ local = if * local { "LOCAL " } else { "" } ,
3980
+ inpath = inpath,
3981
+ overwrite = if * overwrite { "OVERWRITE " } else { "" } ,
3982
+ table_name = table_name,
3983
+ ) ?;
3984
+ if let Some ( ref parts) = & partitioned {
3985
+ if !parts. is_empty ( ) {
3986
+ write ! ( f, " PARTITION ({})" , display_comma_separated( parts) ) ?;
3987
+ }
3988
+ }
3989
+ if let Some ( HiveLoadDataFormat {
3990
+ serde,
3991
+ input_format,
3992
+ } ) = & table_format
3993
+ {
3994
+ write ! ( f, " INPUTFORMAT {input_format} SERDE {serde}" ) ?;
3995
+ }
3996
+ Ok ( ( ) )
3997
+ }
3952
3998
Statement :: CreateVirtualTable {
3953
3999
name,
3954
4000
if_not_exists,
@@ -5855,6 +5901,14 @@ pub enum HiveRowFormat {
5855
5901
DELIMITED { delimiters : Vec < HiveRowDelimiter > } ,
5856
5902
}
5857
5903
5904
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
5905
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
5906
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
5907
+ pub struct HiveLoadDataFormat {
5908
+ pub serde : Expr ,
5909
+ pub input_format : Expr ,
5910
+ }
5911
+
5858
5912
#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
5859
5913
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
5860
5914
#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
0 commit comments