[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3488: [CARBONDATA-3599] Support insert data from stage files written by SDK

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3488: [CARBONDATA-3599] Support insert data from stage files written by SDK

GitBox
ajantha-bhat commented on a change in pull request #3488: [CARBONDATA-3599] Support insert data from stage files written by SDK
URL: https://github.com/apache/carbondata/pull/3488#discussion_r360680167
 
 

 ##########
 File path: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonInsertFromStageCommand.scala
 ##########
 @@ -0,0 +1,376 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.command.management
+
+import java.io.{InputStreamReader, IOException}
+import java.util
+import java.util.Collections
+import java.util.concurrent.{Executors, ExecutorService}
+
+import scala.collection.JavaConverters._
+
+import com.google.gson.Gson
+import org.apache.hadoop.conf.Configuration
+import org.apache.log4j.Logger
+import org.apache.spark.sql.{CarbonEnv, Row, SparkSession}
+import org.apache.spark.sql.execution.command.{Checker, DataCommand}
+import org.apache.spark.sql.util.SparkSQLUtil
+
+import org.apache.carbondata.common.exceptions.sql.MalformedCarbonCommandException
+import org.apache.carbondata.common.logging.LogServiceFactory
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.datastore.filesystem.CarbonFile
+import org.apache.carbondata.core.datastore.impl.FileFactory
+import org.apache.carbondata.core.locks.{CarbonLockFactory, CarbonLockUtil, ICarbonLock, LockUsage}
+import org.apache.carbondata.core.metadata.SegmentFileStore
+import org.apache.carbondata.core.metadata.schema.table.CarbonTable
+import org.apache.carbondata.core.statusmanager.{SegmentStatus, SegmentStatusManager, StageInput}
+import org.apache.carbondata.core.util.path.CarbonTablePath
+import org.apache.carbondata.processing.loading.FailureCauses
+import org.apache.carbondata.processing.loading.model.CarbonLoadModel
+import org.apache.carbondata.processing.util.CarbonLoaderUtil
+import org.apache.carbondata.spark.load.DataLoadProcessBuilderOnSpark
+
+/**
+ * Collect stage input files and trigger a loading into carbon table.
+ *
+ * @param databaseNameOp database name
+ * @param tableName table name
+ */
+case class CarbonInsertFromStageCommand(
+    databaseNameOp: Option[String],
+    tableName: String
+) extends DataCommand {
+
+  @transient var LOGGER: Logger = _
+
+  override def processData(spark: SparkSession): Seq[Row] = {
+    LOGGER = LogServiceFactory.getLogService(this.getClass.getCanonicalName)
+    Checker.validateTableExists(databaseNameOp, tableName, spark)
+    val table = CarbonEnv.getCarbonTable(databaseNameOp, tableName)(spark)
+    val hadoopConf = spark.sessionState.newHadoopConf()
+    FileFactory.getConfiguration.addResource(hadoopConf)
+    setAuditTable(table)
+
+    if (!table.getTableInfo.isTransactionalTable) {
+      throw new MalformedCarbonCommandException("Unsupported operation on non transactional table")
+    }
+
+    val tablePath = table.getTablePath
+    val stagePath = CarbonTablePath.getStageDir(tablePath)
+    val snapshotFilePath = CarbonTablePath.getStageSnapshotFile(tablePath)
+    var loadModel: CarbonLoadModel = null
+    val lock = acquireIngestLock(table)
+
+    try {
+      // 1. Check whether we need to recover from previous failure
+      // We use a snapshot file to indicate whether there was failure in previous
+      // ingest operation. A Snapshot file will be created when an ingest operation
+      // starts and will be deleted only after the whole ingest operation is finished,
+      // which includes two actions:
 
 Review comment:
   I saw "acquireIngestLock" this now. It is already handled.

----------------------------------------------------------------
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]


With regards,
Apache Git Services