Github user ravipesala commented on a diff in the pull request: https://github.com/apache/carbondata/pull/1469#discussion_r153062424 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/hive/CarbonFileMetastore.scala --- @@ -115,18 +121,37 @@ class CarbonFileMetastore extends CarbonMetaStore { lookupRelation(TableIdentifier(tableName, dbName))(sparkSession) } + val rm = universe.runtimeMirror(getClass.getClassLoader) + + def getField[T: TypeTag : reflect.ClassTag](name: String, obj: T): CatalogTable = { + val im = rm.reflect(obj) + val sym = im.symbol.typeSignature.member(TermName(name)) + val tableMeta = im.reflectMethod(sym.asMethod).apply() + tableMeta.asInstanceOf[CatalogTable] + } + override def lookupRelation(tableIdentifier: TableIdentifier) (sparkSession: SparkSession): LogicalPlan = { val database = tableIdentifier.database.getOrElse( sparkSession.catalog.currentDatabase) val relation = sparkSession.sessionState.catalog.lookupRelation(tableIdentifier) match { case SubqueryAlias(_, - LogicalRelation(carbonDatasourceHadoopRelation: CarbonDatasourceHadoopRelation, _, _), - _) => + LogicalRelation(carbonDatasourceHadoopRelation: CarbonDatasourceHadoopRelation, _, _)) => carbonDatasourceHadoopRelation.carbonRelation case LogicalRelation( carbonDatasourceHadoopRelation: CarbonDatasourceHadoopRelation, _, _) => carbonDatasourceHadoopRelation.carbonRelation + case SubqueryAlias(_, c: CatalogRelation) if sparkSession.version.contains("2.2") && + getField("tableMeta", c) + .asInstanceOf[CatalogTable].provider + .isDefined && + getField("tableMeta", c) + .asInstanceOf[CatalogTable].provider.get + .equals("org.apache.spark.sql.CarbonSource") => --- End diff -- Indentation and format is wrong.
---