fix: table and database conflicts (#491)

* fix: table conflicts in different database, #483

* feat: support db query param in prometheus remoting read/write

* feat: support db query param in influxdb line protocol

* fix: make schema_name work in gRPC

* fix: table data path

* fix: table manifest dir

* feat: adds opendal logging layer to object store

* Update src/frontend/src/instance.rs

Co-authored-by: LFC <bayinamine@gmail.com>

* Update src/frontend/src/instance.rs

Co-authored-by: LFC <bayinamine@gmail.com>

* Update src/servers/src/line_writer.rs

Co-authored-by: Lei, Huang <6406592+v0y4g3r@users.noreply.github.com>

* Update src/servers/src/line_writer.rs

Co-authored-by: Lei, Huang <6406592+v0y4g3r@users.noreply.github.com>

* fix: compile error

* ci: use larger runner for running coverage

* fix: address already in use in test

Co-authored-by: LFC <bayinamine@gmail.com>
Co-authored-by: Lei, Huang <6406592+v0y4g3r@users.noreply.github.com>
This commit is contained in:
dennis zhuang
2022-11-14 23:16:52 +08:00
committed by GitHub
parent 76732d6506
commit 448e8f139e
26 changed files with 514 additions and 161 deletions

View File

@@ -1,9 +1,23 @@
use std::fmt::{self, Display};
use std::sync::Arc;
use crate::error::Result;
use crate::requests::{AlterTableRequest, CreateTableRequest, DropTableRequest, OpenTableRequest};
use crate::TableRef;
/// Represents a resolved path to a table of the form “catalog.schema.table”
pub struct TableReference<'a> {
pub catalog: &'a str,
pub schema: &'a str,
pub table: &'a str,
}
impl<'a> Display for TableReference<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}.{}.{}", self.catalog, self.schema, self.table)
}
}
/// Table engine abstraction.
#[async_trait::async_trait]
pub trait TableEngine: Send + Sync {
@@ -37,11 +51,14 @@ pub trait TableEngine: Send + Sync {
) -> Result<TableRef>;
/// Returns the table by it's name.
fn get_table(&self, ctx: &EngineContext, name: &str) -> Result<Option<TableRef>>;
fn get_table<'a>(
&self,
ctx: &EngineContext,
table_ref: &'a TableReference,
) -> Result<Option<TableRef>>;
/// Returns true when the given table is exists.
/// TODO(hl): support catalog and schema
fn table_exists(&self, ctx: &EngineContext, name: &str) -> bool;
fn table_exists<'a>(&self, ctx: &EngineContext, table_ref: &'a TableReference) -> bool;
/// Drops the given table.
async fn drop_table(&self, ctx: &EngineContext, request: DropTableRequest) -> Result<()>;
@@ -52,3 +69,19 @@ pub type TableEngineRef = Arc<dyn TableEngine>;
/// Storage engine context.
#[derive(Debug, Clone, Default)]
pub struct EngineContext {}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_table_reference() {
let table_ref = TableReference {
catalog: "greptime",
schema: "public",
table: "test",
};
assert_eq!("greptime.public.test", table_ref.to_string());
}
}

View File

@@ -6,7 +6,7 @@ use tokio::sync::Mutex;
use crate::test_util::EmptyTable;
use crate::{
engine::{EngineContext, TableEngine},
engine::{EngineContext, TableEngine, TableReference},
requests::{AlterTableRequest, CreateTableRequest, DropTableRequest, OpenTableRequest},
Result, TableRef,
};
@@ -73,11 +73,15 @@ impl TableEngine for MockTableEngine {
unimplemented!()
}
fn get_table(&self, _ctx: &EngineContext, _name: &str) -> Result<Option<TableRef>> {
fn get_table<'a>(
&self,
_ctx: &EngineContext,
_ref: &'a TableReference,
) -> Result<Option<TableRef>> {
unimplemented!()
}
fn table_exists(&self, _ctx: &EngineContext, _name: &str) -> bool {
fn table_exists<'a>(&self, _ctx: &EngineContext, _name: &'a TableReference) -> bool {
unimplemented!()
}