@@ -3347,6 +3347,22 @@ pub enum Statement {
33473347 channel : Ident ,
33483348 payload : Option < String > ,
33493349 } ,
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+ } ,
33503366}
33513367
33523368impl fmt:: Display for Statement {
@@ -3949,6 +3965,36 @@ impl fmt::Display for Statement {
39493965 Ok ( ( ) )
39503966 }
39513967 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+ }
39523998 Statement :: CreateVirtualTable {
39533999 name,
39544000 if_not_exists,
@@ -5855,6 +5901,14 @@ pub enum HiveRowFormat {
58555901 DELIMITED { delimiters : Vec < HiveRowDelimiter > } ,
58565902}
58575903
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+
58585912#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
58595913#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
58605914#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
0 commit comments