You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ku...@apache.org on 2019/06/13 14:39:58 UTC
[carbondata] branch master updated: [CARBONDATA-3309]Fix MV modular
plan generation failure for spark 2.1
This is an automated email from the ASF dual-hosted git repository.
kunalkapoor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/carbondata.git
The following commit(s) were added to refs/heads/master by this push:
new 38630e3 [CARBONDATA-3309]Fix MV modular plan generation failure for spark 2.1
38630e3 is described below
commit 38630e3a0d7b0338e56c062cef2486b6fece0ed8
Author: akashrn5 <ak...@gmail.com>
AuthorDate: Wed Jun 5 09:18:50 2019 +0530
[CARBONDATA-3309]Fix MV modular plan generation failure for spark 2.1
Problem:
In Spark2.1 version, we have Metastore relation instead of HiveTableRelation
as in current spark. So this case is not handled.
Solution
When it is MetastoreRelaton, get the catalogTable and get all the info from
it to form the ModularRelation, to form the modular plan. Reflection is used to fix this.
This closes #3257
---
.../mv/plans/util/Logical2ModularExtractions.scala | 21 +++++++++++++++++++--
.../org/apache/spark/sql/util/SparkSQLUtil.scala | 1 -
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/datamap/mv/plan/src/main/scala/org/apache/carbondata/mv/plans/util/Logical2ModularExtractions.scala b/datamap/mv/plan/src/main/scala/org/apache/carbondata/mv/plans/util/Logical2ModularExtractions.scala
index abc43ba..3b6c725 100644
--- a/datamap/mv/plan/src/main/scala/org/apache/carbondata/mv/plans/util/Logical2ModularExtractions.scala
+++ b/datamap/mv/plan/src/main/scala/org/apache/carbondata/mv/plans/util/Logical2ModularExtractions.scala
@@ -17,11 +17,12 @@
package org.apache.carbondata.mv.plans.util
-import org.apache.spark.sql.catalyst.catalog.HiveTableRelation
+import org.apache.spark.sql.catalyst.catalog.{CatalogTable, HiveTableRelation}
import org.apache.spark.sql.catalyst.expressions.{Alias, Attribute, AttributeReference, AttributeSet, Expression, NamedExpression, PredicateHelper}
import org.apache.spark.sql.catalyst.plans._
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.execution.datasources.LogicalRelation
+import org.apache.spark.util.{CarbonReflectionUtils, SparkUtil}
import org.apache.carbondata.mv.plans.modular.Flags._
import org.apache.carbondata.mv.plans.modular.JoinEdge
@@ -357,7 +358,23 @@ object ExtractTableModule extends PredicateHelper {
Some(database, table, l.output, Nil, NoFlags, Seq.empty)
case l: LocalRelation => // used for unit test
Some(null, null, l.output, Nil, NoFlags, Seq.empty)
- case _ => None
+ case _ =>
+ // this check is added as we get MetastoreRelation in spark2.1,
+ // this is removed in later spark version
+ // TODO: this check can be removed once 2.1 support is removed from carbon
+ if (SparkUtil.isSparkVersionEqualTo("2.1") &&
+ plan.getClass.getName.equals("org.apache.spark.sql.hive.MetastoreRelation")) {
+ val catalogTable = CarbonReflectionUtils.getFieldOfCatalogTable("catalogTable", plan)
+ .asInstanceOf[CatalogTable]
+ Some(catalogTable.database,
+ catalogTable.identifier.table,
+ plan.output,
+ Nil,
+ NoFlags,
+ Seq.empty)
+ } else {
+ None
+ }
}
}
}
diff --git a/integration/spark-common/src/main/scala/org/apache/spark/sql/util/SparkSQLUtil.scala b/integration/spark-common/src/main/scala/org/apache/spark/sql/util/SparkSQLUtil.scala
index 7903ac7..ec1014a 100644
--- a/integration/spark-common/src/main/scala/org/apache/spark/sql/util/SparkSQLUtil.scala
+++ b/integration/spark-common/src/main/scala/org/apache/spark/sql/util/SparkSQLUtil.scala
@@ -29,7 +29,6 @@ import org.apache.spark.sql.catalyst.plans.logical
import org.apache.spark.sql.catalyst.plans.logical.{ColumnStat, LogicalPlan, Statistics}
import org.apache.spark.sql.catalyst.rules.Rule
import org.apache.spark.sql.internal.{SessionState, SQLConf}
-import org.apache.spark.sql.types.DataType
import org.apache.spark.util.{CarbonReflectionUtils, SerializableConfiguration, SparkUtil, Utils}
object SparkSQLUtil {