Login  Register

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #4031: [CARBONDATA-4073] Added FT for missing scenarios in Presto

Posted by GitBox on Dec 14, 2020; 8:42am
URL: http://apache-carbondata-dev-mailing-list-archive.168.s1.nabble.com/GitHub-carbondata-akkio-97-opened-a-new-pull-request-4031-Presto-UT-optimization-tp103896p104690.html


ajantha-bhat commented on a change in pull request #4031:
URL: https://github.com/apache/carbondata/pull/4031#discussion_r542203408



##########
File path: integration/presto/src/test/scala/org/apache/carbondata/presto/integrationtest/PrestoTestUsingSparkStore.scala
##########
@@ -0,0 +1,328 @@
+/*
+ * 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.carbondata.presto.integrationtest
+
+import java.io.{File}
+import java.util
+
+import org.apache.commons.io.FileUtils
+import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, FunSuiteLike}
+
+import org.apache.carbondata.common.logging.LogServiceFactory
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.datastore.impl.FileFactory
+import org.apache.carbondata.core.util.{CarbonProperties, CarbonUtil}
+import org.apache.carbondata.presto.server.{PrestoServer}
+
+class PrestoTestUsingSparkStore
+  extends FunSuiteLike with BeforeAndAfterAll with BeforeAndAfterEach {
+
+  private val logger = LogServiceFactory
+    .getLogService(classOf[PrestoTestNonTransactionalTableFiles].getCanonicalName)
+
+  private val rootPath = new File(this.getClass.getResource("/").getPath
+                                  + "../../../..").getCanonicalPath
+  private val storePath = s"$rootPath/integration/presto/target/store"
+  private val writerPath = storePath + "/presto_spark_db/files"
+  private val sparkStorePath = s"$rootPath/integration/spark/target/spark_store"
+  private val prestoServer = new PrestoServer
+
+  override def beforeAll: Unit = {
+    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME,
+      "Presto")
+    val map = new util.HashMap[String, String]()
+    map.put("hive.metastore", "file")
+    map.put("hive.metastore.catalog.dir", s"file://$storePath")
+    prestoServer.startServer("presto_spark_db", map)
+    prestoServer.execute("drop schema if exists presto_spark_db")
+    prestoServer.execute("create schema presto_spark_db")
+  }
+
+  override def afterAll(): Unit = {
+    prestoServer.stopServer()
+    CarbonUtil.deleteFoldersAndFiles(FileFactory.getCarbonFile(storePath))
+     CarbonUtil.deleteFoldersAndFiles(FileFactory.getCarbonFile
+     (s"$sparkStorePath"))
+  }
+
+  def copyStoreContents(tableName: String): Any = {
+    FileUtils.deleteDirectory(new File(writerPath))
+    import java.io.IOException
+    val source = s"$sparkStorePath/$tableName/"
+    val srcDir = new File(source)
+
+    val destination = s"$storePath/presto_spark_db" +
+                      s"/$tableName/"
+    val destDir = new File(destination)
+    try {
+      // Move spark store to presto store path
+      FileUtils.copyDirectory(srcDir, destDir)
+    }
+    catch {
+      case e: IOException =>
+        e.printStackTrace()

Review comment:
       no need to print trace




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