Skip to content

Commit 3fe9f2f

Browse files
committed
chore: minor fix
1 parent 700910f commit 3fe9f2f

File tree

4 files changed

+45
-8
lines changed

4 files changed

+45
-8
lines changed

src/datanode/src/sql/copy_table.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use datafusion::physical_plan::RecordBatchStream;
2424
use futures::TryStreamExt;
2525
use object_store::services::fs::Builder;
2626
use object_store::ObjectStore;
27-
use snafu::ResultExt;
28-
use table::engine::TableReference;
27+
use snafu::{OptionExt, ResultExt};
28+
use table::engine::{EngineContext, TableReference};
2929
use table::requests::CopyTableRequest;
3030

3131
use crate::error::{self, Result};
@@ -39,7 +39,15 @@ impl SqlHandler {
3939
table: &req.table_name.to_string(),
4040
};
4141

42-
let table = self.get_table(&table_ref)?;
42+
let table = self
43+
.table_engine()
44+
.get_table(&EngineContext::default(), &table_ref)
45+
.context(error::GetTableSnafu {
46+
table_name: table_ref.to_string(),
47+
})?
48+
.context(error::TableNotFoundSnafu {
49+
table_name: table_ref.to_string(),
50+
})?;
4351

4452
let stream = table
4553
.scan(None, &[], None)
@@ -48,14 +56,12 @@ impl SqlHandler {
4856
table_name: table_ref.to_string(),
4957
})?;
5058

51-
let session_ctx = SessionContext::new();
5259
let stream = stream
53-
.execute(0, session_ctx.task_ctx())
60+
.execute(0, SessionContext::default().task_ctx())
5461
.context(error::TableScanExecSnafu)?;
5562
let stream = Box::pin(DfRecordBatchStreamAdapter::new(stream));
5663

57-
// TODO(jiachun): make this configurable
58-
let accessor = Builder::default().root(".").build().unwrap();
64+
let accessor = Builder::default().build().unwrap();
5965
let object_store = ObjectStore::new(accessor);
6066

6167
let mut parquet_writer = ParquetWriter::new(req.file_name, stream, object_store);
@@ -84,7 +90,7 @@ impl ParquetWriter {
8490
object_store,
8591
// TODO(jiachun): make these configurable
8692
max_row_group_size: 4096,
87-
max_rows_in_segment: 100000,
93+
max_rows_in_segment: 1000000,
8894
}
8995
}
9096

src/frontend/src/instance.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,9 @@ pub fn check_permission(
576576
Statement::DescribeTable(stmt) => {
577577
validate_param(stmt.name(), query_ctx)?;
578578
}
579+
Statement::Copy(stmd) => {
580+
validate_param(stmd.table_name(), query_ctx)?;
581+
}
579582
}
580583
Ok(())
581584
}

src/sql/src/parsers/copy_parser.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2023 Greptime Team
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
use snafu::ResultExt;
216
use sqlparser::keywords::Keyword;
317

src/sql/src/statements/copy.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2023 Greptime Team
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
use sqlparser::ast::ObjectName;
216

317
#[derive(Debug, Clone, PartialEq, Eq)]

0 commit comments

Comments
 (0)