mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-28 19:00:39 +00:00
feat: Implement delete for table (#801)
* feat: Table default implementations for insert/alter return error * feat: Implement delete for mito table * docs: Fix comment
This commit is contained in:
@@ -102,6 +102,9 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Failed to operate table, source: {}", source))]
|
||||
TableOperation { source: BoxedError },
|
||||
|
||||
#[snafu(display("Unsupported operation: {}", operation))]
|
||||
Unsupported { operation: String },
|
||||
}
|
||||
|
||||
impl ErrorExt for Error {
|
||||
@@ -119,6 +122,7 @@ impl ErrorExt for Error {
|
||||
Error::SchemaBuild { source, .. } => source.status_code(),
|
||||
Error::TableOperation { source } => source.status_code(),
|
||||
Error::ColumnNotExists { .. } => StatusCode::TableColumnNotFound,
|
||||
Error::Unsupported { .. } => StatusCode::Unsupported,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,3 +90,12 @@ pub struct DropTableRequest {
|
||||
pub schema_name: String,
|
||||
pub table_name: String,
|
||||
}
|
||||
|
||||
/// Delete (by primary key) request
|
||||
#[derive(Debug)]
|
||||
pub struct DeleteRequest {
|
||||
/// Values of each column in this table's primary key and time index.
|
||||
///
|
||||
/// The key is the column name, and the value is the column value.
|
||||
pub key_column_values: HashMap<String, VectorRef>,
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ use common_query::logical_plan::Expr;
|
||||
use common_query::physical_plan::PhysicalPlanRef;
|
||||
use datatypes::schema::SchemaRef;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::error::{Result, UnsupportedSnafu};
|
||||
use crate::metadata::{FilterPushDownType, TableId, TableInfoRef, TableType};
|
||||
use crate::requests::{AlterTableRequest, InsertRequest};
|
||||
use crate::requests::{AlterTableRequest, DeleteRequest, InsertRequest};
|
||||
|
||||
pub type AlterContext = anymap::Map<dyn Any + Send + Sync>;
|
||||
|
||||
@@ -49,8 +49,13 @@ pub trait Table: Send + Sync {
|
||||
}
|
||||
|
||||
/// Insert values into table.
|
||||
///
|
||||
/// Returns number of inserted rows.
|
||||
async fn insert(&self, _request: InsertRequest) -> Result<usize> {
|
||||
unimplemented!();
|
||||
UnsupportedSnafu {
|
||||
operation: "INSERT",
|
||||
}
|
||||
.fail()?
|
||||
}
|
||||
|
||||
/// Scan the table and returns a SendableRecordBatchStream.
|
||||
@@ -71,9 +76,22 @@ pub trait Table: Send + Sync {
|
||||
Ok(FilterPushDownType::Unsupported)
|
||||
}
|
||||
|
||||
async fn alter(&self, _context: AlterContext, request: AlterTableRequest) -> Result<()> {
|
||||
let _ = request;
|
||||
unimplemented!()
|
||||
/// Alter table.
|
||||
async fn alter(&self, _context: AlterContext, _request: AlterTableRequest) -> Result<()> {
|
||||
UnsupportedSnafu {
|
||||
operation: "ALTER TABLE",
|
||||
}
|
||||
.fail()?
|
||||
}
|
||||
|
||||
/// Delete rows in the table.
|
||||
///
|
||||
/// Returns number of deleted rows.
|
||||
async fn delete(&self, _request: DeleteRequest) -> Result<usize> {
|
||||
UnsupportedSnafu {
|
||||
operation: "DELETE",
|
||||
}
|
||||
.fail()?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user