Skip to content
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(cubestore): Aggregating index #4379

Merged
merged 12 commits into from
Jun 23, 2022
Merged

feat(cubestore): Aggregating index #4379

merged 12 commits into from
Jun 23, 2022

Conversation

waralex
Copy link
Contributor

@waralex waralex commented Apr 13, 2022

Check List

  • Tests has been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Description of Changes Made (if issue reference is not provided)

Implementation of aggregating indexes

@waralex waralex requested a review from a team as a code owner April 13, 2022 18:37
@waralex waralex marked this pull request as draft April 13, 2022 18:37
@github-actions github-actions bot added the pr:community Contribution from Cube.js community members. label Apr 13, 2022
@ryanpei ryanpei mentioned this pull request May 11, 2022
2 tasks
@rpaik rpaik added Roadmap: 2022 Q2 Cube roadmap for Q2 of 2022 and removed pr:community Contribution from Cube.js community members. labels May 11, 2022
@rpaik rpaik linked an issue May 11, 2022 that may be closed by this pull request
2 tasks
@rpaik rpaik added backend:pre-aggregations Issues related to pre-aggregations backend:cube-store Issues relating to Cube Store and removed backend:pre-aggregations Issues related to pre-aggregations labels May 11, 2022
@waralex waralex requested a review from cristipp May 12, 2022 16:15
Copy link
Contributor

@cristipp cristipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks generally good. Left a few small comments. To be clear, this is not implementing aggregate index support, merely adding the SQL syntax in preparation for actually building the aggregate indices, right?

tokio::fs::File::create(path_2.clone()).await.unwrap(),
));

file.write_all("platform,age,gender,cnt,max_id\n".as_bytes())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating test tables by hand is getting tedious. Can we please extract it into a function and invoke it like

    let paths = create_test_files([
        r#"
            "iOS", 20, "M", 10, 100,
            "android", 20, "M", 2, 10,
           <etc>
       "#
     ])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right, I'll do this refactoring next time I need to create such table for tests.

loop {
let is_aggregate = self.parse_custom_token("aggregate");

if self.parser.parse_keyword(Keyword::INDEX) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit confusing. How about:

  if self.parse_custom_token("aggregate").is_ok() {
    self.parser.parse_keyword(Keyword::INDEX)?
    indexes.push(self.parse_with_index(name.clone(), true)?;
  } else if self.parser.parse_keyword(Keyword::INDEX).is_ok() {
    indexes.push(self.parse_with_index(name.clone(), false)?;
  } else {
    break;
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I probably will do that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done at 286edbd

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment say's "done at 286edbd", but I still see the old version. Perhaps you forgot tp push, or I'm seeing a stale version from some weird reason?

) -> Result<SQLStatement, ParserError> {
let index_name = self.parser.parse_object_name()?;
self.parser.expect_token(&Token::LParen)?;
let columns = self
.parser
.parse_comma_separated(Parser::parse_order_by_expr)?;
self.parser.expect_token(&Token::RParen)?;
//TODO I use unique flag for aggregate index for reusing CreateIndex struct. When adding another type of index, we will need to parse it into a custom structure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nooooooo ;) Can we please add a separate flag and not re-use something with the wrong name/semantics?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't add a separate flag, because it is structure from sql-parser.rs, but we can write our own structure and write our own parser flow for indexes. Maybe you're right and I should do it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of accumulating differences in private forks of OS projects, but adding a flag to a struct sounds like a minimal change. https://github.com/cube-js/sqlparser-rs

rust/cubestore/cubestore/src/metastore/mod.rs Show resolved Hide resolved
rust/cubestore/cubestore/src/store/mod.rs Outdated Show resolved Hide resolved
rust/cubestore/cubestore/src/store/mod.rs Outdated Show resolved Hide resolved
rust/cubestore/cubestore/src/store/mod.rs Outdated Show resolved Hide resolved
rust/cubestore/cubestore/src/store/mod.rs Outdated Show resolved Hide resolved
@waralex
Copy link
Contributor Author

waralex commented May 13, 2022

Looks generally good. Left a few small comments. To be clear, this is not implementing aggregate index support, merely adding the SQL syntax in preparation for actually building the aggregate indices, right?

Yep, it's a first sub task. I'll merge next steps into this branch, so at the end it will be full implementation of aggregate index

Copy link
Contributor

@cristipp cristipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great. I don't have any more ideas on how to improve the code, so it's all yours :)

loop {
let is_aggregate = self.parse_custom_token("aggregate");

if self.parser.parse_keyword(Keyword::INDEX) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment say's "done at 286edbd", but I still see the old version. Perhaps you forgot tp push, or I'm seeing a stale version from some weird reason?

rust/cubestore/cubestore/src/metastore/mod.rs Show resolved Hide resolved
rust/cubestore/cubestore/src/metastore/mod.rs Show resolved Hide resolved
) -> Result<SQLStatement, ParserError> {
let index_name = self.parser.parse_object_name()?;
self.parser.expect_token(&Token::LParen)?;
let columns = self
.parser
.parse_comma_separated(Parser::parse_order_by_expr)?;
self.parser.expect_token(&Token::RParen)?;
//TODO I use unique flag for aggregate index for reusing CreateIndex struct. When adding another type of index, we will need to parse it into a custom structure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of accumulating differences in private forks of OS projects, but adding a flag to a struct sounds like a minimal change. https://github.com/cube-js/sqlparser-rs

@waralex waralex marked this pull request as ready for review June 23, 2022 13:34
@waralex waralex requested a review from a team as a code owner June 23, 2022 13:34
@waralex waralex merged commit a0bd36c into master Jun 23, 2022
@waralex waralex deleted the features/aggregating_index branch June 23, 2022 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:cube-store Issues relating to Cube Store Roadmap: 2022 Q2 Cube roadmap for Q2 of 2022
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Epic: Caching performance
3 participants