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

Design of MaterializedViewQuery #6977

Open
leventov opened this issue Feb 1, 2019 · 5 comments
Open

Design of MaterializedViewQuery #6977

leventov opened this issue Feb 1, 2019 · 5 comments

Comments

@leventov
Copy link
Member

leventov commented Feb 1, 2019

Currently, #5556 implements it as MaterializedViewQuery and MaterializedViewQueryQueryToolChest, i. e. in the same type framework as Query and QueryToolChest. However, MaterializedViewQuery and MaterializedViewQueryQueryToolChest are shallow and pass-through classes. MaterializedViewQueryQueryToolChest couldn't sensibly return something from getResultTypeReference(), so I wonder why it didn't throw NPE in DirectDruidClient before, but I hit this problem in my change #6898.

There should probably be an abstraction like "query modifier" and other parts of the infrastructure should recognize it.

cc @zhangxinyu1 @jihoonson

@sascha-coenen
Copy link

sascha-coenen commented Feb 10, 2019

I would propose to model materialized views as a new type of datasource instead of requiring a json wrapper around existing query types as is the current solution.
So instead of

{ 
  "queryType": "view", 
  "query": { 
    "queryType": "groupBy", 
    "dataSource": "wikiticker", 
    "granularity": "all"
    ...
  }
}

I would use the existing functionality of having different types of dataSource references to indicate that the query is to be executed on a view instead of a raw datasource like so:

{ 
    "type": "groupBy", 
    "dataSource": {
        "type": "view",
        "name": "wikiticker"
    }, 
    "granularity": "all"
    ...
}

Ref to druid documentation about different types of datasources: http://druid.io/docs/latest/querying/datasource.html

Basically, with this approach, a materialized view would be structurally equivalent to a union query.

When dataSource.type is set to "view", then the query would scan segments of the master table and any related cuboids and when setting the type to table, one could direct Druid to explicitly query only a particular materialized cuboid.

Another advantage would be that it would be more straightforward to add support for materialized views in client frameworks like plywood/pivot plyql/dsql because no json wrapper is needed anymore, just a new type of an existing syntactical building block

@leventov
Copy link
Member Author

@sascha-coenen sounds interesting, would you like to make this a proposal?

@jihoonson
Copy link
Contributor

@sascha-coenen sounds good to me too.

@zhangxinyu1
Copy link
Contributor

@sascha-coenen Thanks for your suggestion, "view datasource" is more appropriate.

@github-actions
Copy link

github-actions bot commented Aug 1, 2023

This issue has been marked as stale due to 280 days of inactivity.
It will be closed in 4 weeks if no further activity occurs. If this issue is still
relevant, please simply write any comment. Even if closed, you can still revive the
issue at any time or discuss it on the [email protected] list.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants