support spec char as delimiter

Signed-off-by: junxiang Mu <1948535941@qq.com>
This commit is contained in:
junxiang Mu
2025-05-06 11:00:18 +08:00
parent fc47ca9dd2
commit 0ac1095c70
11 changed files with 139 additions and 39 deletions
+6 -4
View File
@@ -49,7 +49,7 @@ lazy_static! {
#[derive(Clone)]
pub struct SimpleQueryDispatcher {
input: SelectObjectContentInput,
input: Arc<SelectObjectContentInput>,
// client for default tenant
_default_table_provider: TableHandleProviderRef,
session_factory: Arc<SessionCtxFactory>,
@@ -164,7 +164,9 @@ impl SimpleQueryDispatcher {
.map(|e| e.as_bytes().first().copied().unwrap_or_default()),
);
if let Some(delimiter) = csv.field_delimiter.as_ref() {
file_format = file_format.with_delimiter(delimiter.as_bytes().first().copied().unwrap_or_default());
if delimiter.len() == 1 {
file_format = file_format.with_delimiter(delimiter.as_bytes()[0]);
}
}
// TODO waiting for processing @junxiang Mu
// if csv.file_header_info.is_some() {}
@@ -272,7 +274,7 @@ impl Stream for TrackedRecordBatchStream {
#[derive(Default, Clone)]
pub struct SimpleQueryDispatcherBuilder {
input: Option<SelectObjectContentInput>,
input: Option<Arc<SelectObjectContentInput>>,
default_table_provider: Option<TableHandleProviderRef>,
session_factory: Option<Arc<SessionCtxFactory>>,
parser: Option<Arc<dyn Parser + Send + Sync>>,
@@ -283,7 +285,7 @@ pub struct SimpleQueryDispatcherBuilder {
}
impl SimpleQueryDispatcherBuilder {
pub fn with_input(mut self, input: SelectObjectContentInput) -> Self {
pub fn with_input(mut self, input: Arc<SelectObjectContentInput>) -> Self {
self.input = Some(input);
self
}
+8 -6
View File
@@ -63,7 +63,7 @@ where
}
}
pub async fn make_rustfsms(input: SelectObjectContentInput, is_test: bool) -> QueryResult<impl DatabaseManagerSystem> {
pub async fn make_rustfsms(input: Arc<SelectObjectContentInput>, is_test: bool) -> QueryResult<impl DatabaseManagerSystem> {
// init Function Manager, we can define some UDF if need
let func_manager = SimpleFunctionMetadataManager::default();
// TODO session config need load global system config
@@ -95,6 +95,8 @@ pub async fn make_rustfsms(input: SelectObjectContentInput, is_test: bool) -> Qu
#[cfg(test)]
mod tests {
use std::sync::Arc;
use api::{
query::{Context, Query},
server::dbms::DatabaseManagerSystem,
@@ -111,7 +113,7 @@ mod tests {
#[ignore]
async fn test_simple_sql() {
let sql = "select * from S3Object";
let input = SelectObjectContentInput {
let input = Arc::new(SelectObjectContentInput {
bucket: "dandan".to_string(),
expected_bucket_owner: None,
key: "test.csv".to_string(),
@@ -135,7 +137,7 @@ mod tests {
request_progress: None,
scan_range: None,
},
};
});
let db = make_rustfsms(input.clone(), true).await.unwrap();
let query = Query::new(Context { input }, sql.to_string());
@@ -167,8 +169,8 @@ mod tests {
#[tokio::test]
#[ignore]
async fn test_func_sql() {
let sql = "SELECT s._1 FROM S3Object s";
let input = SelectObjectContentInput {
let sql = "SELECT * FROM S3Object s";
let input = Arc::new(SelectObjectContentInput {
bucket: "dandan".to_string(),
expected_bucket_owner: None,
key: "test.csv".to_string(),
@@ -194,7 +196,7 @@ mod tests {
request_progress: None,
scan_range: None,
},
};
});
let db = make_rustfsms(input.clone(), true).await.unwrap();
let query = Query::new(Context { input }, sql.to_string());