-
Notifications
You must be signed in to change notification settings - Fork 762
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
feat(query): create drop inverted index #14859
Conversation
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.
Reviewed 14 of 43 files at r1.
Reviewable status: 14 of 44 files reviewed, 1 unresolved discussion (waiting on @b41sh and @sundy-li)
src/meta/api/src/schema_api_impl.rs
line 4013 at r1 (raw file):
UnknownIndex::new(&tenant_index.index_name, "drop index with different type"), ))); }
An index
is uniquely identified by index_type
at line 3985, does it have to check index_type
?
Code quote:
if index_type != &index_meta.index_type {
return Err(KVAppError::AppError(AppError::UnknownIndex(
UnknownIndex::new(&tenant_index.index_name, "drop index with different type"),
)));
}
The aggregating index and the inverted index have different drop syntaxes, DROP AGGREGATING INDEX idx1;
DROP INVERTED INDEX idx1; The main reason for checking the index type here is to avoid using the wrong drop syntax, for example: CREATE AGGREGATING INDEX my_agg_index AS SELECT MIN(a), MAX(c) FROM agg;
DROP INVERTED INDEX my_agg_index; |
Is it allowed for an aggregating index and an inverted index to have same index name? For example: CREATE AGGREGATING INDEX aaa ...;
CREATE INVERTED INDEX aaa ...; |
Same name is not allowed. |
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.
Reviewed all commit messages.
Reviewable status: 14 of 45 files reviewed, 2 unresolved discussions (waiting on @b41sh and @sundy-li)
src/meta/app/src/schema/index.rs
line 96 at r3 (raw file):
AGGREGATING = 1, JOIN = 2, INVERTED = 3,
Adding a variant is a incompatible change. In a cluster of new-query and old-query running together, the old-query that can not read INVERTED
will return an error
Seems reasonable, new-query should remove this new meta to downgrade. |
@TCeason had solved a similar compatibility issue like this. What's the correct way for adding a enum variant? |
We can store the data for the inverted index separately, but this will bring some duplicate code, is there a better way to solve this problem? |
PriviligeType is bitflag. Use from_bits_truncate. let privileges =
BitFlags::<mt::principal::UserPrivilegeType, u64>::from_bits_truncate(p.privileges); |
Now index type uses from i32. So we can add a compat test for it? like this:
|
If there is an incompatible variant, ![]() |
Returning an error makes the index unusable, which is unacceptable. Inverted indexes are for a single table, whereas aggregating indexes are for multiple tables, so it seems better to define them separately. Can we define a new inverted index and put it in TableMeta? |
Aggregating index also for single table, but one table can have multiple aggregating indexes. |
It would be more clear and neat. |
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.
Reviewed 6 of 72 files at r4, all commit messages.
Reviewable status: 7 of 78 files reviewed, 3 unresolved discussions (waiting on @ariesdevil, @b41sh, and @sundy-li)
src/meta/app/src/schema/table.rs
line 258 at r4 (raw file):
pub struct TableIndex { pub name: String, pub columns: Vec<String>,
If a column is renamed, columns
becomes invalid.
The column_id
should be used instead of String
. column_id
are unique.
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.
Reviewed 1 of 72 files at r4, 3 of 15 files at r5, all commit messages.
Reviewable status: 9 of 78 files reviewed, 4 unresolved discussions (waiting on @ariesdevil, @b41sh, and @sundy-li)
src/meta/api/src/schema_api_impl.rs
line 3186 at r5 (raw file):
column_ids: req.column_ids.clone(), }; indexes.insert(req.name.clone(), index);
The column_ids
is passed in via the CreateTableIndexReq
, the column ids may have changed in the TableMeta
fetched at line 3115.
There are two options to address this issue:
- Confirm that the column ids from
CreateTableIndexReq
present in theTableMeta
' - Specify column by names in the
CreateTableIdnexReq
, and translate them to column-id in this method.
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.
Reviewed 30 of 72 files at r4, 3 of 15 files at r5, 3 of 10 files at r6, all commit messages.
Reviewable status: 42 of 78 files reviewed, 2 unresolved discussions (waiting on @ariesdevil, @b41sh, and @sundy-li)
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
create_table_index
anddrop_table_index
apiTests
Type of change
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)