mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-21 07:20:41 +00:00
* fix: Delete statement not supported in metric engine close #4649 Signed-off-by: yihong0618 <zouzou0208@gmail.com> * fix: do not include Truncate address review comments Signed-off-by: yihong0618 <zouzou0208@gmail.com> * fix: address comments Signed-off-by: yihong0618 <zouzou0208@gmail.com> * fix: address comment again Signed-off-by: yihong0618 <zouzou0208@gmail.com> --------- Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
@@ -163,8 +163,18 @@ impl RegionEngine for MetricEngine {
|
||||
}
|
||||
}
|
||||
RegionRequest::Flush(req) => self.inner.flush_region(region_id, req).await,
|
||||
RegionRequest::Delete(_) | RegionRequest::Truncate(_) => {
|
||||
UnsupportedRegionRequestSnafu { request }.fail()
|
||||
RegionRequest::Truncate(_) => UnsupportedRegionRequestSnafu { request }.fail(),
|
||||
RegionRequest::Delete(_) => {
|
||||
if self.inner.is_physical_region(region_id) {
|
||||
self.inner
|
||||
.mito
|
||||
.handle_request(region_id, request)
|
||||
.await
|
||||
.context(error::MitoDeleteOperationSnafu)
|
||||
.map(|response| response.affected_rows)
|
||||
} else {
|
||||
UnsupportedRegionRequestSnafu { request }.fail()
|
||||
}
|
||||
}
|
||||
RegionRequest::Catchup(req) => self.inner.catchup_region(region_id, req).await,
|
||||
};
|
||||
|
||||
@@ -125,6 +125,12 @@ pub enum Error {
|
||||
#[snafu(implicit)]
|
||||
location: Location,
|
||||
},
|
||||
#[snafu(display("Mito delete operation fails"))]
|
||||
MitoDeleteOperation {
|
||||
source: BoxedError,
|
||||
#[snafu(implicit)]
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Mito catchup operation fails"))]
|
||||
MitoCatchupOperation {
|
||||
@@ -288,7 +294,8 @@ impl ErrorExt for Error {
|
||||
| MitoReadOperation { source, .. }
|
||||
| MitoWriteOperation { source, .. }
|
||||
| MitoCatchupOperation { source, .. }
|
||||
| MitoFlushOperation { source, .. } => source.status_code(),
|
||||
| MitoFlushOperation { source, .. }
|
||||
| MitoDeleteOperation { source, .. } => source.status_code(),
|
||||
|
||||
EncodePrimaryKey { source, .. } => source.status_code(),
|
||||
|
||||
|
||||
@@ -107,6 +107,16 @@ SELECT * from t1;
|
||||
| host1 | 1970-01-01T00:00:00 | 0.0 |
|
||||
+-------+-------------------------+-----+
|
||||
|
||||
-- issue #4649 should fail (do not support delete from logical table for now)
|
||||
delete from t1;
|
||||
|
||||
Error: 1001(Unsupported), Unsupported region request: Delete
|
||||
|
||||
-- issue #4649 should succeed
|
||||
delete from phy;
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
CREATE TABLE t2 (ts timestamp time index, job string primary key, val double) engine = metric with ("on_physical_table" = "phy");
|
||||
|
||||
Affected Rows: 0
|
||||
@@ -143,12 +153,8 @@ select * from foo;
|
||||
|
||||
SELECT * from t1;
|
||||
|
||||
+-------+-------------------------+-----+
|
||||
| host | ts | val |
|
||||
+-------+-------------------------+-----+
|
||||
| host2 | 1970-01-01T00:00:00.001 | 1.0 |
|
||||
| host1 | 1970-01-01T00:00:00 | 0.0 |
|
||||
+-------+-------------------------+-----+
|
||||
++
|
||||
++
|
||||
|
||||
SELECT * from t2;
|
||||
|
||||
|
||||
@@ -47,6 +47,12 @@ INSERT INTO t1 VALUES ('host1',0, 0), ('host2', 1, 1,);
|
||||
|
||||
SELECT * from t1;
|
||||
|
||||
-- issue #4649 should fail (do not support delete from logical table for now)
|
||||
delete from t1;
|
||||
|
||||
-- issue #4649 should succeed
|
||||
delete from phy;
|
||||
|
||||
CREATE TABLE t2 (ts timestamp time index, job string primary key, val double) engine = metric with ("on_physical_table" = "phy");
|
||||
|
||||
SELECT * from t2;
|
||||
|
||||
Reference in New Issue
Block a user