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

[CARBONDATA-3689] Support independent MV extension and MV syntax #3609

Closed
wants to merge 1 commit into from

Conversation

jackylk
Copy link
Contributor

@jackylk jackylk commented Feb 10, 2020

Why is this PR needed?

To better promote Materialized View usage, we can make Materialized View as an independent extension for Apache Spark

What changes were proposed in this PR?

This PR adds Materialized View extension for spark:
Following SQL command are supported:

  1. CREATE MATERIALIZED VIEW
  2. DROP MATERIALIZED VIEW
  3. SHOW MATERIALIZED VIEW
  4. REFRESH MATERIALIZED VIEW

Following optimizer rules are added:

  1. Rewrite SQL statement by matching existing MV and
    select the lowest cost MV

Does this PR introduce any user interface change?

  • Yes. (new SQL syntax is added)

Is any new testcase added?

  • No (existing Datamap testcase is modified to use MV syntax)

@CarbonDataQA1
Copy link

Build Failed with Spark 2.4.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.4/215/

@CarbonDataQA1
Copy link

Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/1917/

@CarbonDataQA1
Copy link

Build Failed with Spark 2.4.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.4/218/

@CarbonDataQA1
Copy link

Build Success with Spark 2.4.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.4/220/

@CarbonDataQA1
Copy link

Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/1922/

@jackylk
Copy link
Contributor Author

jackylk commented Feb 11, 2020

retest this please

@CarbonDataQA1
Copy link

Build Success with Spark 2.4.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.4/223/

@jackylk jackylk changed the title [WIP] Support MV extension and MV syntax [CARBONDATA-3689] Support independent MV extension and MV syntax Feb 11, 2020
@CarbonDataQA1
Copy link

Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/1925/

@jackylk
Copy link
Contributor Author

jackylk commented Feb 11, 2020

retest this please

@CarbonDataQA1
Copy link

Build Success with Spark 2.4.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.4/238/

@CarbonDataQA1
Copy link

Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/1940/

* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
Copy link
Contributor

Choose a reason for hiding this comment

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

why License is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@CarbonDataQA1
Copy link

Build Success with Spark 2.4.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.4/256/

@CarbonDataQA1
Copy link

Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/1959/

* MVPROPERTIES('KEY'='VALUE') AS mv_query_statement
*/
private lazy val createMV: Parser[LogicalPlan] =
CREATE ~> MATERIALIZED ~> VIEW ~> opt(IF ~> NOT ~> EXISTS) ~ ident ~
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
CREATE ~> MATERIALIZED ~> VIEW ~> opt(IF ~> NOT ~> EXISTS) ~ ident ~
CREATE ~> MATERIALIZED ~> VIEW ~> opt(IF ~> NOT ~> EXISTS) ~ ident ~ ontable ~(ident <~ ".").? ~ ident-

i suggest db.table name can be provided while creating materilaised views, which will be helpful in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On table is not required because MV can be a join, so I think better not forcing user to give this.
Is there any helpful scenario for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

for supporting multi-tenant, it can be useful in creating mv under a specified database in create command

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For supporting multi-tenant, I think the mv table should be created under current database, just like a create normal table does. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

what if user creates mv from different database, where database's involved in query is different.

* DROP MATERIALIZED VIEW IF EXISTS mv_name
*/
private lazy val dropMV: Parser[LogicalPlan] =
DROP ~> MATERIALIZED ~> VIEW ~> opt(IF ~> EXISTS) ~ ident <~ opt(";") ^^ {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
DROP ~> MATERIALIZED ~> VIEW ~> opt(IF ~> EXISTS) ~ ident <~ opt(";") ^^ {
DROP ~> MATERIALIZED ~> VIEW ~> opt(IF ~> EXISTS) ~ ident ~ONTABLE ~ (ident <~ ".").? ~ ident<~ opt(";") ^^ {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On table is not required because MV can be a join, so I think better not forcing user to give this

* REBUILD MATERIALIZED VIEW mv_name
*/
private lazy val rebuildMV: Parser[LogicalPlan] =
REBUILD ~> MATERIALIZED ~> VIEW ~> ident <~ opt(";") ^^ {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
REBUILD ~> MATERIALIZED ~> VIEW ~> ident <~ opt(";") ^^ {
REBUILD ~> MATERIALIZED ~> VIEW ~> ident ~ ONTABLE ~ (ident <~ ".").? ~ ident<~ opt(";") ^^ {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On table is not required because MV can be a join, so I think better not forcing user to give this

@CarbonDataQA1
Copy link

Build Success with Spark 2.4.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.4/282/

@CarbonDataQA1
Copy link

Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/1985/

@CarbonDataQA1
Copy link

Build Success with Spark 2.4.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.4/286/

@CarbonDataQA1
Copy link

Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/1989/

@CarbonDataQA1
Copy link

Build Success with Spark 2.4.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.4/290/

@CarbonDataQA1
Copy link

Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/1994/

@CarbonDataQA1
Copy link

Build Success with Spark 2.4.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.4/300/

@CarbonDataQA1
Copy link

Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2004/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants