Skip to content

Commit 851bd3a

Browse files
authored
Merge pull request #10561 from youngsofun/trans
feat: support copy into table with transform.
2 parents efb5d8f + bd6d5ff commit 851bd3a

File tree

16 files changed

+731
-239
lines changed

16 files changed

+731
-239
lines changed

src/query/ast/src/ast/statements/stage.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ pub struct SelectStageOptions {
9090
pub connection: BTreeMap<String, String>,
9191
}
9292

93+
impl SelectStageOptions {
94+
pub fn is_empty(&self) -> bool {
95+
self.files.is_none()
96+
&& self.pattern.is_none()
97+
&& self.file_format.is_none()
98+
&& self.connection.is_empty()
99+
}
100+
}
101+
93102
// SELECT <columns> FROM
94103
// {@<stage_name>[/<path>] | '<uri>'} [(
95104
// [ PARTTERN => '<regex_pattern>']

src/query/catalog/src/plan/datasource/datasource_info/parquet.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use common_arrow::arrow::datatypes::Schema as ArrowSchema;
1818
use common_expression::TableSchema;
1919
use common_meta_app::principal::StageInfo;
2020
use common_meta_app::schema::TableInfo;
21+
use common_storage::StageFileInfo;
2122
use common_storage::StageFilesInfo;
2223

2324
use crate::plan::datasource::datasource_info::parquet_read_options::ParquetReadOptions;
@@ -30,6 +31,7 @@ pub struct ParquetTableInfo {
3031

3132
pub table_info: TableInfo,
3233
pub arrow_schema: ArrowSchema,
34+
pub files_to_read: Option<Vec<StageFileInfo>>,
3335
}
3436

3537
impl ParquetTableInfo {

src/query/catalog/src/table_context.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ use common_io::prelude::FormatSettings;
3030
use common_meta_app::principal::FileFormatOptions;
3131
use common_meta_app::principal::RoleInfo;
3232
use common_meta_app::principal::UserInfo;
33+
use common_meta_app::schema::TableCopiedFileInfo;
3334
use common_settings::Settings;
3435
use common_storage::DataOperator;
36+
use common_storage::StageFileInfo;
3537
use common_storage::StorageMetrics;
3638

3739
use crate::catalog::Catalog;
@@ -133,4 +135,20 @@ pub trait TableContext: Send + Sync {
133135

134136
async fn get_table(&self, catalog: &str, database: &str, table: &str)
135137
-> Result<Arc<dyn Table>>;
138+
139+
async fn color_copied_files(
140+
&self,
141+
catalog_name: &str,
142+
database_name: &str,
143+
table_name: &str,
144+
files: Vec<StageFileInfo>,
145+
) -> Result<Vec<StageFileInfo>>;
146+
147+
async fn upsert_copied_files(
148+
&self,
149+
catalog_name: &str,
150+
database_name: &str,
151+
table_name: &str,
152+
copy_stage_files: BTreeMap<String, TableCopiedFileInfo>,
153+
) -> Result<()>;
136154
}

0 commit comments

Comments
 (0)