feat: implement Arrow Flight "DoPut" in Frontend (#5836)

* feat: implement Arrow Flight "DoPut" in Frontend

* support auth for "do_put"

* set request_id in DoPut requests and responses

* set "db" in request header
This commit is contained in:
LFC
2025-04-17 11:46:19 +08:00
committed by GitHub
parent fdab5d198e
commit d27b9fc3a1
26 changed files with 944 additions and 185 deletions

View File

@@ -172,6 +172,9 @@ pub enum Error {
#[snafu(implicit)]
location: Location,
},
#[snafu(display("Invalid table name: '{s}'"))]
InvalidTableName { s: String },
}
impl ErrorExt for Error {
@@ -197,7 +200,8 @@ impl ErrorExt for Error {
Error::MissingTimeIndexColumn { .. } => StatusCode::IllegalState,
Error::InvalidTableOptionValue { .. }
| Error::SetSkippingOptions { .. }
| Error::UnsetSkippingOptions { .. } => StatusCode::InvalidArguments,
| Error::UnsetSkippingOptions { .. }
| Error::InvalidTableName { .. } => StatusCode::InvalidArguments,
}
}

View File

@@ -15,8 +15,12 @@
use std::fmt::{Display, Formatter};
use api::v1::TableName as PbTableName;
use common_catalog::consts::{DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME};
use serde::{Deserialize, Serialize};
use snafu::ensure;
use crate::error;
use crate::error::InvalidTableNameSnafu;
use crate::table_reference::TableReference;
#[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize, Serialize)]
@@ -83,3 +87,37 @@ impl From<TableReference<'_>> for TableName {
Self::new(table_ref.catalog, table_ref.schema, table_ref.table)
}
}
impl TryFrom<Vec<String>> for TableName {
type Error = error::Error;
fn try_from(v: Vec<String>) -> Result<Self, Self::Error> {
ensure!(
!v.is_empty() && v.len() <= 3,
InvalidTableNameSnafu {
s: format!("{v:?}")
}
);
let mut v = v.into_iter();
match (v.next(), v.next(), v.next()) {
(Some(catalog_name), Some(schema_name), Some(table_name)) => Ok(Self {
catalog_name,
schema_name,
table_name,
}),
(Some(schema_name), Some(table_name), None) => Ok(Self {
catalog_name: DEFAULT_CATALOG_NAME.to_string(),
schema_name,
table_name,
}),
(Some(table_name), None, None) => Ok(Self {
catalog_name: DEFAULT_CATALOG_NAME.to_string(),
schema_name: DEFAULT_SCHEMA_NAME.to_string(),
table_name,
}),
// Unreachable because it's ensured that "v" is not empty,
// and its iterator will not yield `Some` after `None`.
_ => unreachable!(),
}
}
}