-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Metadata trait #1096
Support Metadata trait #1096
Conversation
Remove Store trait related cfg features, (gluesql#1091) Enable all by default. Compile time feature control causes too much management cost. We already have test cases in test-suite splitted based on store trait features. Support `values` query in AST builder (gluesql#1041) Currently, ASTBuilder does not support Values Query yet. This PR supports Values Query in ASTBuilder e.g. let actual = values(vec!["1, 'a'", "2, 'b'"]) .order_by(vec!["column1 desc"]) .build(); let expected = "VALUES(1, 'a'), (2, 'b') ORDER BY column1 desc";
Pull Request Test Coverage Report for Build 4586977286
💛 - Coveralls |
storages/memory-storage/src/lib.rs
Outdated
@@ -68,21 +72,52 @@ impl Store for MemoryStorage { | |||
} | |||
} | |||
|
|||
#[async_trait(?Send)] | |||
impl Metadata for MemoryStorage { | |||
async fn scan_meta(&self) -> HashMap<String, Value> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async function scan_metadata(&self) -> Result<Box<dyn Iterator<Item = Result<(String, Value)>>>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks that we can simply use HashMap<String, Value>
rather than Value
.
storages/memory-storage/src/lib.rs
Outdated
pub struct MemoryStorage { | ||
pub id_counter: i64, | ||
pub items: HashMap<String, Item>, | ||
pub metadata: HashMap<String, Value>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub metadata: HashMap<String, HashMap<String, Value>>,
this would be more precise..?
test-suite/src/metadata/mod.rs
Outdated
pub mod table; | ||
pub use table::table; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can provide two different ways to use module.
Like other modules we are using,
ref. https://github.com/gluesql/gluesql/blob/main/test-suite/src/data_type/mod.rs
How about only using pub mod table;
?
core/src/store/mod.rs
Outdated
|
||
pub trait GStoreMut: StoreMut + IndexMut + AlterTable + Transaction {} | ||
impl<S: StoreMut + IndexMut + AlterTable + Transaction> GStoreMut for S {} | ||
|
||
pub use { | ||
self::metadata::{MetaIter, Metadata}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like other modules, alter_table
, data_row
..
we can omit self::
core/src/executor/fetch.rs
Outdated
let meta = table_metas.iter().find_map(|(table_name, hash_map)| { | ||
if table_name == &schema.table_name { | ||
Some(Value::Map(hash_map.clone())) | ||
} else { | ||
None | ||
} | ||
}); | ||
let table_row = HashMap::from([ | ||
("OBJECT_NAME".to_owned(), Value::Str(schema.table_name)), | ||
("OBJECT_TYPE".to_owned(), Value::Str("TABLE".to_owned())), | ||
]); | ||
|
||
let table_rows = match meta { | ||
Some(Value::Map(meta)) => { | ||
table_row.into_iter().chain(meta).collect() | ||
} | ||
_ => table_row, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks that we can reduce use of collect
.
let meta = table_metas
.iter()
.find_map(|(table_name, hash_map)| {
(table_name == &schema.table_name).then(|| hash_map.clone())
})
.unwrap_or_default();
let table_rows = [
("OBJECT_NAME".to_owned(), Value::Str(schema.table_name)),
("OBJECT_TYPE".to_owned(), Value::Str("TABLE".to_owned())),
]
.into_iter()
.chain(meta);
storages/memory-storage/src/lib.rs
Outdated
@@ -71,18 +75,30 @@ impl Store for MemoryStorage { | |||
#[async_trait(?Send)] | |||
impl StoreMut for MemoryStorage { | |||
async fn insert_schema(&mut self, schema: &Schema) -> Result<()> { | |||
let created = HashMap::from([ | |||
("OBJECT_TYPE".to_owned(), Value::Str("TABLE".to_owned())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would not be necessary because which the same OBJECT_TYPE
property is being used in execution layer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed OBJECT_TYPE in this PR but it may be needed if we implement metadata of index later since only OBJECT_NAME is used as a key here.
Just in case TABLE_NAME and INDEX_NAME are identical (but object_types are different), both OBJECT_NAME and OBJECT_TYPE should be a key
Or need some separated stored area between table and index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great!
All looks nice 👍 Thanks a lot 👍 👍
Goal
CREATED
field of Table and IndexTodo
CREATED
from GLUE_OBJECTS of coreCREATED
to generate_metadata_tests