@@ -91,6 +91,7 @@ use databend_common_pipeline_core::InputError;
9191use databend_common_pipeline_core:: LockGuard ;
9292use databend_common_settings:: Settings ;
9393use databend_common_sql:: IndexType ;
94+ use databend_common_storage:: init_stage_operator;
9495use databend_common_storage:: CopyStatus ;
9596use databend_common_storage:: DataOperator ;
9697use databend_common_storage:: FileStatus ;
@@ -1514,6 +1515,14 @@ impl TableContext for QueryContext {
15141515 max_column_position : usize ,
15151516 case_sensitive : bool ,
15161517 ) -> Result < Arc < dyn Table > > {
1518+ let operator = init_stage_operator ( & stage_info) ?;
1519+ let info = operator. info ( ) ;
1520+ let stage_root = format ! ( "{}{}" , info. name( ) , info. root( ) ) ;
1521+ let stage_root = if stage_root. ends_with ( '/' ) {
1522+ stage_root
1523+ } else {
1524+ format ! ( "{}/" , stage_root)
1525+ } ;
15171526 match stage_info. file_format_params {
15181527 FileFormatParams :: Parquet ( ..) => {
15191528 let mut read_options = ParquetReadOptions :: default ( ) ;
@@ -1553,6 +1562,7 @@ impl TableContext for QueryContext {
15531562 default_values : None ,
15541563 copy_into_location_options : Default :: default ( ) ,
15551564 copy_into_table_options : Default :: default ( ) ,
1565+ stage_root,
15561566 } ;
15571567 OrcTable :: try_create ( info) . await
15581568 }
@@ -1571,6 +1581,7 @@ impl TableContext for QueryContext {
15711581 default_values : None ,
15721582 copy_into_location_options : Default :: default ( ) ,
15731583 copy_into_table_options : Default :: default ( ) ,
1584+ stage_root,
15741585 } ;
15751586 StageTable :: try_create ( info)
15761587 }
@@ -1607,6 +1618,7 @@ impl TableContext for QueryContext {
16071618 default_values : None ,
16081619 copy_into_location_options : Default :: default ( ) ,
16091620 copy_into_table_options : Default :: default ( ) ,
1621+ stage_root,
16101622 } ;
16111623 StageTable :: try_create ( info)
16121624 }
0 commit comments