Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1837#discussion_r163757600
--- Diff:
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonLoadDataCommand.scala
---
@@ -87,12 +84,41 @@ case class CarbonLoadDataCommand(
options: scala.collection.immutable.Map[String, String],
isOverwriteTable: Boolean,
var inputSqlString: String = null,
- dataFrame: Option[DataFrame] = None,
+ var dataFrame: Option[DataFrame] = None,
updateModel: Option[UpdateTableModel] = None,
var tableInfoOp: Option[TableInfo] = None,
- internalOptions: Map[String, String] = Map.empty,
- partition: Map[String, Option[String]] = Map.empty) extends
DataCommand {
+ var internalOptions: Map[String, String] = Map.empty,
+ partition: Map[String, Option[String]] = Map.empty,
+ logicalPlan: Option[LogicalPlan] = None,
+ var operationContext: OperationContext = new OperationContext) extends
AtomicRunnableCommand {
+ var table: CarbonTable = _
+
+ override def processMetadata(sparkSession: SparkSession): Seq[Row] = {
+ val LOGGER: LogService =
LogServiceFactory.getLogService(this.getClass.getCanonicalName)
+ val dbName = CarbonEnv.getDatabaseName(databaseNameOp)(sparkSession)
+ table = if (tableInfoOp.isDefined) {
+ CarbonTable.buildFromTableInfo(tableInfoOp.get)
+ } else {
+ val relation = CarbonEnv.getInstance(sparkSession).carbonMetastore
+ .lookupRelation(Option(dbName),
tableName)(sparkSession).asInstanceOf[CarbonRelation]
+ if (relation == null) {
+ throw new NoSuchTableException(dbName, tableName)
+ }
+ if (null == relation.carbonTable) {
+ LOGGER.error(s"Data loading failed. table not found:
$dbName.$tableName")
+ LOGGER.audit(s"Data loading failed. table not found:
$dbName.$tableName")
+ throw new NoSuchTableException(dbName, tableName)
+ }
+ relation.carbonTable
+ }
+ operationContext.setProperty("isOverwrite", isOverwriteTable)
+ if (CarbonUtil.hasAggregationDataMap(table)) {
+ val loadMetadataEvent = new LoadMetadataEvent(table, false)
+ OperationListenerBus.getInstance().fireEvent(loadMetadataEvent,
operationContext)
--- End diff --
Always fire the event here, handle if condition inside the registered
listner
---