[GitHub] [carbondata] akashrn5 opened a new pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] akashrn5 opened a new pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox

akashrn5 opened a new pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916


    ### Why is this PR needed?
    Currently, we support only reading the tables created in spark in presto. Its a bottleneck and writing the trasactional is required
   in presto for easy write and read via presto.
   
    ### What changes were proposed in this PR?
   This PR iis on top of #3875
    This PR supports writing the partition transactional data in presto, it supports multiple partition columns too.
   
    ### Does this PR introduce any user interface change?
    - No
   
    ### Is any new testcase added?
     - Yes
   
       
   


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox

CarbonDataQA1 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-689046280


   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2270/
   


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-689055659


   Build Failed  with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4010/
   


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-696055322


   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2404/
   


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-696064427


   Build Failed  with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4145/
   


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-696055322






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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-697922443


   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2454/
   


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-697924469


   Build Failed  with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4197/
   


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-704164039


   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2564/
   


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-704164989


   Build Failed  with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4314/
   


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] QiangCai commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

QiangCai commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-714868177


   please do rebase


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ajantha-bhat commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

ajantha-bhat commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-717003123


   @akashrn5 : please rebase as presto write PR is merged


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] akashrn5 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

akashrn5 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-717074706


   @ajantha-bhat i have rebased, please have a look.


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] akashrn5 edited a comment on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

akashrn5 edited a comment on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-717074706


   @ajantha-bhat @QiangCai i have rebased, please have a look.


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

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



##########
File path: core/src/main/java/org/apache/carbondata/core/constants/CarbonCommonConstants.java
##########
@@ -369,7 +369,8 @@ private CarbonCommonConstants() {
   public static final String CARBON_MERGE_INDEX_IN_SEGMENT =
       "carbon.merge.index.in.segment";
 
-  public static final String CARBON_MERGE_INDEX_IN_SEGMENT_DEFAULT = "true";
+  // TODO: revert this after proper fix in this PR

Review comment:
       please revert this

##########
File path: integration/hive/src/main/java/org/apache/carbondata/hive/MapredCarbonOutputCommitter.java
##########
@@ -123,13 +132,46 @@ public void commitJob(JobContext jobContext) throws IOException {
     try {
       Configuration configuration = jobContext.getConfiguration();
       CarbonLoadModel carbonLoadModel = MapredCarbonOutputFormat.getLoadModel(configuration);
-      ThreadLocalSessionInfo.unsetAll();
-      SegmentFileStore.writeSegmentFile(carbonLoadModel.getCarbonDataLoadSchema().getCarbonTable(),
-          carbonLoadModel.getSegmentId(), String.valueOf(carbonLoadModel.getFactTimeStamp()));
-      SegmentFileStore
-          .mergeIndexAndWriteSegmentFile(carbonLoadModel.getCarbonDataLoadSchema().getCarbonTable(),
-              carbonLoadModel.getSegmentId(), String.valueOf(carbonLoadModel.getFactTimeStamp()));
-      CarbonTableOutputFormat.setLoadModel(configuration, carbonLoadModel);
+      if (!carbonLoadModel.getCarbonDataLoadSchema().getCarbonTable().isHivePartitionTable()) {
+        ThreadLocalSessionInfo.unsetAll();
+        SegmentFileStore
+            .writeSegmentFile(carbonLoadModel.getCarbonDataLoadSchema().getCarbonTable(),
+                carbonLoadModel.getSegmentId(), String.valueOf(carbonLoadModel.getFactTimeStamp()));
+        SegmentFileStore.mergeIndexAndWriteSegmentFile(
+            carbonLoadModel.getCarbonDataLoadSchema().getCarbonTable(),
+            carbonLoadModel.getSegmentId(), String.valueOf(carbonLoadModel.getFactTimeStamp()));
+        CarbonTableOutputFormat.setLoadModel(configuration, carbonLoadModel);
+      } else {
+        String tableFactLocation =
+            carbonLoadModel.getCarbonDataLoadSchema().getCarbonTable().getTablePath();
+        List<CarbonFile> carbonFiles =
+            FileFactory.getCarbonFile(tableFactLocation).listFiles(true, new CarbonFileFilter() {

Review comment:
       list files of whole table can be very slow when multiple segments are present. we list previous load segments also here. I think we need to keep list of index/merge index created for current load in memory and write in the segment file here.

##########
File path: integration/hive/src/main/java/org/apache/carbondata/hive/MapredCarbonOutputFormat.java
##########
@@ -115,9 +115,20 @@ public void checkOutputSpecs(FileSystem fileSystem, JobConf jobConf) throws IOEx
         carbonLoadModel.getCarbonDataLoadSchema().getCarbonTable().getPartitionInfo();
     final int partitionColumn =
         partitionInfo != null ? partitionInfo.getColumnSchemaList().size() : 0;
+    final String finalOutputPath;
     if (carbonLoadModel.getCarbonDataLoadSchema().getCarbonTable().isHivePartitionTable()) {
-      carbonLoadModel.getMetrics().addToPartitionPath(finalOutPath.toString());
-      context.getConfiguration().set("carbon.outputformat.writepath", finalOutPath.toString());
+      String[] outputPathSplits = finalOutPath.toString().split("/");
+      StringBuilder partitionDirs = new StringBuilder();
+      for (int i = partitionColumn; i > 0;  i--) {

Review comment:
       so, how carbondata-hive partition write is working ?  

##########
File path: integration/presto/src/test/scala/org/apache/carbondata/presto/integrationtest/PrestoInsertIntoPartitionTableTestCase.scala
##########
@@ -0,0 +1,184 @@
+/*
+ * 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 java.util.concurrent.atomic.AtomicInteger
+
+import scala.collection.JavaConverters._
+
+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.filesystem.{CarbonFile, CarbonFileFilter}
+import org.apache.carbondata.core.datastore.impl.FileFactory
+import org.apache.carbondata.core.metadata.{AbsoluteTableIdentifier, SegmentFileStore}
+import org.apache.carbondata.core.metadata.datatype.{DataTypes, StructField}
+import org.apache.carbondata.core.metadata.schema.{PartitionInfo, SchemaReader}
+import org.apache.carbondata.core.metadata.schema.partition.PartitionType
+import org.apache.carbondata.core.metadata.schema.table.TableSchemaBuilder
+import org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema
+import org.apache.carbondata.core.statusmanager.SegmentStatusManager
+import org.apache.carbondata.core.util.{CarbonProperties, CarbonUtil}
+import org.apache.carbondata.core.util.path.CarbonTablePath
+import org.apache.carbondata.presto.server.PrestoServer
+
+/**
+ * Tests for partition tables transational write in presto
+ */
+class PrestoInsertIntoPartitionTableTestCase
+  extends FunSuiteLike with BeforeAndAfterAll with BeforeAndAfterEach {
+
+  private val logger = LogServiceFactory
+    .getLogService(classOf[PrestoAllDataTypeTest].getCanonicalName)
+
+  private val rootPath = new File(this.getClass.getResource("/").getPath
+                                  + "../../../..").getCanonicalPath
+  private val storePath = s"$rootPath/integration/presto/target/store"
+  private val prestoServer = new PrestoServer
+
+  override def beforeAll: Unit = {
+    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME,

Review comment:
       remove written by, it has to take care internally




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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ajantha-bhat commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

ajantha-bhat commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-717124467


   @akashrn5
   a) Please update the PR description about what all problems were there and what changes done to support it. Now it is not clear.
   b) Please confirm here whether the cluster test is passed.


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-717126479


   Build Failed  with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4700/
   


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


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3916: [CARBONDATA-3935]Support partition table transactional write in presto

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3916:
URL: https://github.com/apache/carbondata/pull/3916#issuecomment-717126913


   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2943/
   


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