[GitHub] [carbondata] Indhumathi27 opened a new pull request #4038: [WIP] Fix MV having Subquery alias used in query projection

classic Classic list List threaded Threaded
35 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 opened a new pull request #4038: [WIP] Fix MV having Subquery alias used in query projection

GitBox

Indhumathi27 opened a new pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038


    ### Why is this PR needed?
   
   
    ### What changes were proposed in this PR?
   
       
    ### Does this PR introduce any user interface change?
    - No
    - Yes. (please explain the change and update document)
   
    ### Is any new testcase added?
    - No
    - Yes
   
       
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [WIP] Fix MV having Subquery alias used in query projection

GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-738012712


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


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [WIP] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-738017364


   Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/3288/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-739817981


   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/3325/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-739818381


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


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-739818889


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


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-739819277


   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/3351/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] brijoobopanna commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

brijoobopanna commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-739941445


   retest this please
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-740012068


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


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-740014655


   Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12444/job/ApacheCarbon_PR_Builder_2.4.5/3338/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-740083489


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


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-740083832


   Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12444/job/ApacheCarbon_PR_Builder_2.4.5/3341/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] akashrn5 commented on a change in pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

akashrn5 commented on a change in pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#discussion_r543346052



##########
File path: integration/spark/src/main/scala/org/apache/spark/sql/optimizer/MVMatcher.scala
##########
@@ -803,6 +836,9 @@ private object SelectSelectNoChildDelta extends MVMatchPattern with PredicateHel
         sel_3q @ modular.Select(_, _, _, _, _, _, _, _, _, _), None)
         if sel_3a.children.forall(_.isInstanceOf[GroupBy]) &&
            sel_3q.children.forall(_.isInstanceOf[GroupBy]) =>
+        LOGGER.debug(

Review comment:
       same as above and please change in all places.

##########
File path: integration/spark/src/main/scala/org/apache/spark/sql/optimizer/MVMatcher.scala
##########
@@ -647,6 +680,10 @@ private object SelectSelectNoChildDelta extends MVMatchPattern with PredicateHel
         ) if sel_1a.children.forall { _.isInstanceOf[modular.LeafNode] } &&
              sel_1q.children.forall { _.isInstanceOf[modular.LeafNode] } =>
 
+        LOGGER.debug(
+          "Applying pattern: {SelectSelectNoChildDelta} for the plan: {" +
+          subsumee.toString().trim + " }. Current Subsumer: {" + subsumer.toString().trim + " }")

Review comment:
       do not use the `+`, since scala class use `s""`

##########
File path: integration/spark/src/main/scala/org/apache/spark/sql/optimizer/MVMatcher.scala
##########
@@ -228,6 +230,34 @@ private abstract class MVMatchPattern extends Logging {
     }
   }
 
+  /**
+   * Compares the output list of subsumer/subsumee with/without alias. In case if, expression
+   * is instance of Alias, then compare it's child expression.
+   */
+  protected def compareOutputList(outputList1: Seq[NamedExpression],

Review comment:
       rename to `subsumerOutputList` and `subsumeeOutputList`

##########
File path: integration/spark/src/main/scala/org/apache/spark/sql/optimizer/MVRewriteRule.scala
##########
@@ -154,6 +158,9 @@ class MVRewriteRule(session: SparkSession) extends Rule[LogicalPlan] {
       case _ =>
         compactSQL
     }
+    LOGGER.debug("Converting from Modular Plan to Logical Plan for query " +

Review comment:
       you can just add here as rewritten query and print query

##########
File path: integration/spark/src/test/scala/org/apache/carbondata/view/rewrite/MVCreateTestCase.scala
##########
@@ -414,6 +414,20 @@ class MVCreateTestCase extends QueryTest with BeforeAndAfterAll {
     sql(s"drop materialized view mv32")
   }
 
+  test("test create materialized view having sub-query alias used in projection") {
+    sql("drop materialized view if exists mv_sub")
+    val subQuery = "select empname, sum(result) sum_ut from " +
+                   "(select empname, utilization result from fact_table1) fact_table1 " +
+                   "group by empname"
+    sql("create materialized view mv_sub as " + subQuery)

Review comment:
       can you add a test where MV is created on `select empname, utilization result from fact_table1` and then actual query uses this as subquery?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-745860919


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


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-745862054


   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12444/job/ApacheCarbon_PR_Builder_2.4.5/3414/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-746085728


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


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-746088504


   Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12444/job/ApacheCarbon_PR_Builder_2.4.5/3417/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

Indhumathi27 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-746142473


   @akashrn5 Fixed all comments. Please review


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] akashrn5 commented on a change in pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

akashrn5 commented on a change in pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#discussion_r544302352



##########
File path: integration/spark/src/test/scala/org/apache/carbondata/view/rewrite/MVCreateTestCase.scala
##########
@@ -428,6 +428,25 @@ class MVCreateTestCase extends QueryTest with BeforeAndAfterAll {
     sql(s"drop materialized view mv_sub")
   }
 
+  test("test create materialized view used as sub-query in actual query") {
+    sql("drop materialized view if exists mv_sub")
+    sql("create materialized view mv_sub as select empname, utilization result from fact_table1")
+    val df1 = sql("select empname, sum(result) sum_ut from " +
+                  "(select empname, utilization result from fact_table1) fact_table1 " +
+                  "group by empname")
+    val df2 = sql("select emp, sum(result) sum_ut from " +
+                  "(select empname emp, utilization result from fact_table1) fact_table1 " +
+                  "group by emp")
+    assert(TestUtil.verifyMVHit(df1.queryExecution.optimizedPlan, "mv_sub"))

Review comment:
       please add a assert for `df2` also




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA2 commented on pull request #4038: [CARBONDATA-4076] Fix MV having Subquery alias used in query projection

GitBox
In reply to this post by GitBox

CarbonDataQA2 commented on pull request #4038:
URL: https://github.com/apache/carbondata/pull/4038#issuecomment-746593891


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


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


12