You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by GitBox <gi...@apache.org> on 2020/04/13 07:07:02 UTC

[GitHub] [carbondata] kunal642 opened a new pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

kunal642 opened a new pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705
 
 
   …values
   
    ### Why is this PR needed?
    
    
    ### What changes were proposed in this PR?
   
       
    ### Does this PR introduce any user interface change?
    - No
    - Yes. (please explain the change and update document)
   
    ### Is any new testcase added?
    - No
    - 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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] kunal642 commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
kunal642 commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#discussion_r407410789
 
 

 ##########
 File path: core/src/main/java/org/apache/carbondata/core/metadata/SegmentFileStore.java
 ##########
 @@ -320,6 +321,28 @@ public static boolean writeSegmentFileForOthers(
     return false;
   }
 
+  public static void mergeIndexAndWriteSegmentFile(CarbonTable carbonTable, String segmentId,
+      String UUID) {
+    String tablePath = carbonTable.getTablePath();
+    String segmentPath = CarbonTablePath.getSegmentPath(tablePath, segmentId);
+    CarbonFile segmentFolder = FileFactory.getCarbonFile(segmentPath);
+    CarbonFile[] indexFiles = segmentFolder.listFiles(new CarbonFileFilter() {
+      @Override
+      public boolean accept(CarbonFile file) {
+        return (file.getName().endsWith(CarbonTablePath.INDEX_FILE_EXT) || file.getName()
+            .endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT));
+      }
+    });
+    String segmentFileName = genSegmentFileName(segmentId, UUID) + CarbonTablePath.SEGMENT_EXT;
+    try {
+      SegmentFileStore sfs = new SegmentFileStore(tablePath, segmentFileName);
 
 Review comment:
   this is a static method inside SegmentFileStore, not creating sfs object

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#issuecomment-612823808
 
 
   Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2718/
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] kunal642 commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values

Posted by GitBox <gi...@apache.org>.
kunal642 commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values
URL: https://github.com/apache/carbondata/pull/3705#discussion_r407422757
 
 

 ##########
 File path: core/src/main/java/org/apache/carbondata/core/metadata/SegmentFileStore.java
 ##########
 @@ -320,6 +321,28 @@ public static boolean writeSegmentFileForOthers(
     return false;
   }
 
+  public static void mergeIndexAndWriteSegmentFile(CarbonTable carbonTable, String segmentId,
+      String UUID) {
+    String tablePath = carbonTable.getTablePath();
+    String segmentPath = CarbonTablePath.getSegmentPath(tablePath, segmentId);
+    CarbonFile segmentFolder = FileFactory.getCarbonFile(segmentPath);
+    CarbonFile[] indexFiles = segmentFolder.listFiles(new CarbonFileFilter() {
+      @Override
+      public boolean accept(CarbonFile file) {
+        return (file.getName().endsWith(CarbonTablePath.INDEX_FILE_EXT) || file.getName()
+            .endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT));
+      }
+    });
+    String segmentFileName = genSegmentFileName(segmentId, UUID) + CarbonTablePath.SEGMENT_EXT;
+    try {
+      SegmentFileStore sfs = new SegmentFileStore(tablePath, segmentFileName);
 
 Review comment:
   done

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#issuecomment-612784486
 
 
   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1005/
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] asfgit closed pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values
URL: https://github.com/apache/carbondata/pull/3705
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] kunal642 commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
kunal642 commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#discussion_r407409308
 
 

 ##########
 File path: integration/hive/src/main/java/org/apache/carbondata/hive/Hive2CarbonExpression.java
 ##########
 @@ -103,38 +111,43 @@ public static Expression convertExprHive2Carbon(ExprNodeDesc exprNodeDesc) {
               getDateType(l1.get(left).getTypeString()));
         }
         LiteralExpression literalExpression =
-            new LiteralExpression(l1.get(right).getExprString().replace("'", ""),
+            new LiteralExpression(getExpressionValue(l1.get(right)),
                 getDateType(l1.get(right).getTypeString()));
         return new EqualToExpression(columnExpression, literalExpression);
       } else if (udf instanceof GenericUDFOPEqualOrGreaterThan) {
         ColumnExpression columnExpression = new ColumnExpression(l1.get(left).getCols().get(left),
             getDateType(l1.get(left).getTypeString()));
-        LiteralExpression literalExpression = new LiteralExpression(l1.get(right).getExprString(),
-            getDateType(l1.get(left).getTypeString()));
+        LiteralExpression literalExpression =
 
 Review comment:
   i dont think its good, we would just be replacing 1 line code with a method call. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#issuecomment-612783472
 
 
   Build Failed  with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2717/
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
ajantha-bhat commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#discussion_r407397937
 
 

 ##########
 File path: integration/hive/src/main/java/org/apache/carbondata/hive/Hive2CarbonExpression.java
 ##########
 @@ -103,38 +111,43 @@ public static Expression convertExprHive2Carbon(ExprNodeDesc exprNodeDesc) {
               getDateType(l1.get(left).getTypeString()));
         }
         LiteralExpression literalExpression =
-            new LiteralExpression(l1.get(right).getExprString().replace("'", ""),
+            new LiteralExpression(getExpressionValue(l1.get(right)),
                 getDateType(l1.get(right).getTypeString()));
         return new EqualToExpression(columnExpression, literalExpression);
       } else if (udf instanceof GenericUDFOPEqualOrGreaterThan) {
         ColumnExpression columnExpression = new ColumnExpression(l1.get(left).getCols().get(left),
             getDateType(l1.get(left).getTypeString()));
-        LiteralExpression literalExpression = new LiteralExpression(l1.get(right).getExprString(),
-            getDateType(l1.get(left).getTypeString()));
+        LiteralExpression literalExpression =
 
 Review comment:
   can we make two methods ?
   `makeColumnExpression(l1)
   ``makeLiteralExpression(l1)`
   
   I see lot of duplicate code here

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
ajantha-bhat commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#discussion_r407400600
 
 

 ##########
 File path: integration/hive/src/main/java/org/apache/carbondata/hive/MapredCarbonOutputCommitter.java
 ##########
 @@ -0,0 +1,122 @@
+/*
+ * 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.hive;
+
+import java.io.IOException;
+import java.util.Random;
+import java.util.UUID;
+
+import org.apache.carbondata.common.logging.LogServiceFactory;
+import org.apache.carbondata.core.metadata.SegmentFileStore;
+import org.apache.carbondata.core.util.ThreadLocalSessionInfo;
+import org.apache.carbondata.hadoop.api.CarbonOutputCommitter;
+import org.apache.carbondata.hadoop.api.CarbonTableOutputFormat;
+import org.apache.carbondata.hive.util.HiveCarbonUtil;
+import org.apache.carbondata.processing.loading.model.CarbonLoadModel;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.JobContext;
+import org.apache.hadoop.mapred.OutputCommitter;
+import org.apache.hadoop.mapred.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.JobID;
+import org.apache.hadoop.mapreduce.JobStatus;
+import org.apache.hadoop.mapreduce.TaskAttemptID;
+import org.apache.hadoop.mapreduce.TaskID;
+import org.apache.hadoop.mapreduce.TaskType;
+import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
+import org.apache.log4j.Logger;
+
+public class MapredCarbonOutputCommitter extends OutputCommitter {
+
+  private CarbonOutputCommitter carbonOutputCommitter;
+
+  private final Logger LOGGER =
+      LogServiceFactory.getLogService(this.getClass().getName());
+
+  @Override
+  public void setupJob(JobContext jobContext) throws IOException {
+    ThreadLocalSessionInfo.setConfigurationToCurrentThread(jobContext.getConfiguration());
+    String a = jobContext.getJobConf().get(JobConf.MAPRED_MAP_TASK_ENV);
+    Random random = new Random();
+    JobID jobId = new JobID(UUID.randomUUID().toString(), 0);
+    TaskID task = new TaskID(jobId, TaskType.MAP, random.nextInt());
+    TaskAttemptID attemptID = new TaskAttemptID(task, random.nextInt());
+    org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl context =
+        new TaskAttemptContextImpl(jobContext.getJobConf(), attemptID);
+    CarbonLoadModel carbonLoadModel =
+        HiveCarbonUtil.getCarbonLoadModel(jobContext.getConfiguration());
+    CarbonTableOutputFormat.setLoadModel(jobContext.getConfiguration(), carbonLoadModel);
+    carbonOutputCommitter =
+        new CarbonOutputCommitter(new Path(carbonLoadModel.getTablePath()), context);
+    carbonOutputCommitter.setupJob(jobContext);
+    String loadModelStr = jobContext.getConfiguration().get("mapreduce.carbontable.load.model");
+    jobContext.getJobConf().set(JobConf.MAPRED_MAP_TASK_ENV,
+        a + ",carbon=" + loadModelStr);
+    jobContext.getJobConf().set(JobConf.MAPRED_REDUCE_TASK_ENV,
+        a + ",carbon=" + loadModelStr);
+  }
+
+  @Override
+  public void setupTask(TaskAttemptContext taskAttemptContext) throws IOException {
+
+  }
+
+  @Override
+  public boolean needsTaskCommit(TaskAttemptContext taskAttemptContext) throws IOException {
+    return false;
+  }
+
+  @Override
+  public void commitTask(TaskAttemptContext taskAttemptContext) throws IOException {
+
+  }
+
+  @Override
+  public void abortTask(TaskAttemptContext taskAttemptContext) throws IOException {
+
+  }
+
+  @Override
+  public void abortJob(JobContext jobContext, int status) throws IOException {
+    if (carbonOutputCommitter != null) {
+      carbonOutputCommitter.abortJob(jobContext, JobStatus.State.FAILED);
+      throw new RuntimeException("Failed to commit Job");
+    }
+  }
+
+  @Override
+  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(),
 
 Review comment:
   So, for non transactional table also we write segment files now ?!

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] kunal642 commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values

Posted by GitBox <gi...@apache.org>.
kunal642 commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values
URL: https://github.com/apache/carbondata/pull/3705#discussion_r407410789
 
 

 ##########
 File path: core/src/main/java/org/apache/carbondata/core/metadata/SegmentFileStore.java
 ##########
 @@ -320,6 +321,28 @@ public static boolean writeSegmentFileForOthers(
     return false;
   }
 
+  public static void mergeIndexAndWriteSegmentFile(CarbonTable carbonTable, String segmentId,
+      String UUID) {
+    String tablePath = carbonTable.getTablePath();
+    String segmentPath = CarbonTablePath.getSegmentPath(tablePath, segmentId);
+    CarbonFile segmentFolder = FileFactory.getCarbonFile(segmentPath);
+    CarbonFile[] indexFiles = segmentFolder.listFiles(new CarbonFileFilter() {
+      @Override
+      public boolean accept(CarbonFile file) {
+        return (file.getName().endsWith(CarbonTablePath.INDEX_FILE_EXT) || file.getName()
+            .endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT));
+      }
+    });
+    String segmentFileName = genSegmentFileName(segmentId, UUID) + CarbonTablePath.SEGMENT_EXT;
+    try {
+      SegmentFileStore sfs = new SegmentFileStore(tablePath, segmentFileName);
 
 Review comment:
   this is a static method inside SegmentFileStore, not creating sfs object

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] ajantha-bhat commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values

Posted by GitBox <gi...@apache.org>.
ajantha-bhat commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values
URL: https://github.com/apache/carbondata/pull/3705#issuecomment-612958303
 
 
   LGTM

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] kunal642 commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
kunal642 commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#discussion_r407410789
 
 

 ##########
 File path: core/src/main/java/org/apache/carbondata/core/metadata/SegmentFileStore.java
 ##########
 @@ -320,6 +321,28 @@ public static boolean writeSegmentFileForOthers(
     return false;
   }
 
+  public static void mergeIndexAndWriteSegmentFile(CarbonTable carbonTable, String segmentId,
+      String UUID) {
+    String tablePath = carbonTable.getTablePath();
+    String segmentPath = CarbonTablePath.getSegmentPath(tablePath, segmentId);
+    CarbonFile segmentFolder = FileFactory.getCarbonFile(segmentPath);
+    CarbonFile[] indexFiles = segmentFolder.listFiles(new CarbonFileFilter() {
+      @Override
+      public boolean accept(CarbonFile file) {
+        return (file.getName().endsWith(CarbonTablePath.INDEX_FILE_EXT) || file.getName()
+            .endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT));
+      }
+    });
+    String segmentFileName = genSegmentFileName(segmentId, UUID) + CarbonTablePath.SEGMENT_EXT;
+    try {
+      SegmentFileStore sfs = new SegmentFileStore(tablePath, segmentFileName);
 
 Review comment:
   this is a static method inside SegmentFileStore

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#issuecomment-612833683
 
 
   Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1006/
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values

Posted by GitBox <gi...@apache.org>.
CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values
URL: https://github.com/apache/carbondata/pull/3705#issuecomment-612891626
 
 
   Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2724/
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] ajantha-bhat commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
ajantha-bhat commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#issuecomment-612829869
 
 
   please update the PR description

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
ajantha-bhat commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#discussion_r407400600
 
 

 ##########
 File path: integration/hive/src/main/java/org/apache/carbondata/hive/MapredCarbonOutputCommitter.java
 ##########
 @@ -0,0 +1,122 @@
+/*
+ * 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.hive;
+
+import java.io.IOException;
+import java.util.Random;
+import java.util.UUID;
+
+import org.apache.carbondata.common.logging.LogServiceFactory;
+import org.apache.carbondata.core.metadata.SegmentFileStore;
+import org.apache.carbondata.core.util.ThreadLocalSessionInfo;
+import org.apache.carbondata.hadoop.api.CarbonOutputCommitter;
+import org.apache.carbondata.hadoop.api.CarbonTableOutputFormat;
+import org.apache.carbondata.hive.util.HiveCarbonUtil;
+import org.apache.carbondata.processing.loading.model.CarbonLoadModel;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.JobContext;
+import org.apache.hadoop.mapred.OutputCommitter;
+import org.apache.hadoop.mapred.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.JobID;
+import org.apache.hadoop.mapreduce.JobStatus;
+import org.apache.hadoop.mapreduce.TaskAttemptID;
+import org.apache.hadoop.mapreduce.TaskID;
+import org.apache.hadoop.mapreduce.TaskType;
+import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
+import org.apache.log4j.Logger;
+
+public class MapredCarbonOutputCommitter extends OutputCommitter {
+
+  private CarbonOutputCommitter carbonOutputCommitter;
+
+  private final Logger LOGGER =
+      LogServiceFactory.getLogService(this.getClass().getName());
+
+  @Override
+  public void setupJob(JobContext jobContext) throws IOException {
+    ThreadLocalSessionInfo.setConfigurationToCurrentThread(jobContext.getConfiguration());
+    String a = jobContext.getJobConf().get(JobConf.MAPRED_MAP_TASK_ENV);
+    Random random = new Random();
+    JobID jobId = new JobID(UUID.randomUUID().toString(), 0);
+    TaskID task = new TaskID(jobId, TaskType.MAP, random.nextInt());
+    TaskAttemptID attemptID = new TaskAttemptID(task, random.nextInt());
+    org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl context =
+        new TaskAttemptContextImpl(jobContext.getJobConf(), attemptID);
+    CarbonLoadModel carbonLoadModel =
+        HiveCarbonUtil.getCarbonLoadModel(jobContext.getConfiguration());
+    CarbonTableOutputFormat.setLoadModel(jobContext.getConfiguration(), carbonLoadModel);
+    carbonOutputCommitter =
+        new CarbonOutputCommitter(new Path(carbonLoadModel.getTablePath()), context);
+    carbonOutputCommitter.setupJob(jobContext);
+    String loadModelStr = jobContext.getConfiguration().get("mapreduce.carbontable.load.model");
+    jobContext.getJobConf().set(JobConf.MAPRED_MAP_TASK_ENV,
+        a + ",carbon=" + loadModelStr);
+    jobContext.getJobConf().set(JobConf.MAPRED_REDUCE_TASK_ENV,
+        a + ",carbon=" + loadModelStr);
+  }
+
+  @Override
+  public void setupTask(TaskAttemptContext taskAttemptContext) throws IOException {
+
+  }
+
+  @Override
+  public boolean needsTaskCommit(TaskAttemptContext taskAttemptContext) throws IOException {
+    return false;
+  }
+
+  @Override
+  public void commitTask(TaskAttemptContext taskAttemptContext) throws IOException {
+
+  }
+
+  @Override
+  public void abortTask(TaskAttemptContext taskAttemptContext) throws IOException {
+
+  }
+
+  @Override
+  public void abortJob(JobContext jobContext, int status) throws IOException {
+    if (carbonOutputCommitter != null) {
+      carbonOutputCommitter.abortJob(jobContext, JobStatus.State.FAILED);
+      throw new RuntimeException("Failed to commit Job");
+    }
+  }
+
+  @Override
+  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(),
 
 Review comment:
   So, for non transactional table also we write segment files now ?!

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values

Posted by GitBox <gi...@apache.org>.
CarbonDataQA1 commented on issue #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded values
URL: https://github.com/apache/carbondata/pull/3705#issuecomment-612890262
 
 
   Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1012/
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
ajantha-bhat commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#discussion_r407397053
 
 

 ##########
 File path: core/src/main/java/org/apache/carbondata/core/metadata/SegmentFileStore.java
 ##########
 @@ -320,6 +321,28 @@ public static boolean writeSegmentFileForOthers(
     return false;
   }
 
+  public static void mergeIndexAndWriteSegmentFile(CarbonTable carbonTable, String segmentId,
+      String UUID) {
+    String tablePath = carbonTable.getTablePath();
+    String segmentPath = CarbonTablePath.getSegmentPath(tablePath, segmentId);
+    CarbonFile segmentFolder = FileFactory.getCarbonFile(segmentPath);
+    CarbonFile[] indexFiles = segmentFolder.listFiles(new CarbonFileFilter() {
+      @Override
+      public boolean accept(CarbonFile file) {
+        return (file.getName().endsWith(CarbonTablePath.INDEX_FILE_EXT) || file.getName()
+            .endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT));
+      }
+    });
+    String segmentFileName = genSegmentFileName(segmentId, UUID) + CarbonTablePath.SEGMENT_EXT;
+    try {
+      SegmentFileStore sfs = new SegmentFileStore(tablePath, segmentFileName);
 
 Review comment:
   once SegmentFileStore is made, call `sfs.getIndexFiles()`, we can remove list files of line 329

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …

Posted by GitBox <gi...@apache.org>.
ajantha-bhat commented on a change in pull request #3705: [CARBONDATA-3771] Fixed date filter issue and use hive constants instead of hard-coded …
URL: https://github.com/apache/carbondata/pull/3705#discussion_r407400600
 
 

 ##########
 File path: integration/hive/src/main/java/org/apache/carbondata/hive/MapredCarbonOutputCommitter.java
 ##########
 @@ -0,0 +1,122 @@
+/*
+ * 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.hive;
+
+import java.io.IOException;
+import java.util.Random;
+import java.util.UUID;
+
+import org.apache.carbondata.common.logging.LogServiceFactory;
+import org.apache.carbondata.core.metadata.SegmentFileStore;
+import org.apache.carbondata.core.util.ThreadLocalSessionInfo;
+import org.apache.carbondata.hadoop.api.CarbonOutputCommitter;
+import org.apache.carbondata.hadoop.api.CarbonTableOutputFormat;
+import org.apache.carbondata.hive.util.HiveCarbonUtil;
+import org.apache.carbondata.processing.loading.model.CarbonLoadModel;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.JobContext;
+import org.apache.hadoop.mapred.OutputCommitter;
+import org.apache.hadoop.mapred.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.JobID;
+import org.apache.hadoop.mapreduce.JobStatus;
+import org.apache.hadoop.mapreduce.TaskAttemptID;
+import org.apache.hadoop.mapreduce.TaskID;
+import org.apache.hadoop.mapreduce.TaskType;
+import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
+import org.apache.log4j.Logger;
+
+public class MapredCarbonOutputCommitter extends OutputCommitter {
+
+  private CarbonOutputCommitter carbonOutputCommitter;
+
+  private final Logger LOGGER =
+      LogServiceFactory.getLogService(this.getClass().getName());
+
+  @Override
+  public void setupJob(JobContext jobContext) throws IOException {
+    ThreadLocalSessionInfo.setConfigurationToCurrentThread(jobContext.getConfiguration());
+    String a = jobContext.getJobConf().get(JobConf.MAPRED_MAP_TASK_ENV);
+    Random random = new Random();
+    JobID jobId = new JobID(UUID.randomUUID().toString(), 0);
+    TaskID task = new TaskID(jobId, TaskType.MAP, random.nextInt());
+    TaskAttemptID attemptID = new TaskAttemptID(task, random.nextInt());
+    org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl context =
+        new TaskAttemptContextImpl(jobContext.getJobConf(), attemptID);
+    CarbonLoadModel carbonLoadModel =
+        HiveCarbonUtil.getCarbonLoadModel(jobContext.getConfiguration());
+    CarbonTableOutputFormat.setLoadModel(jobContext.getConfiguration(), carbonLoadModel);
+    carbonOutputCommitter =
+        new CarbonOutputCommitter(new Path(carbonLoadModel.getTablePath()), context);
+    carbonOutputCommitter.setupJob(jobContext);
+    String loadModelStr = jobContext.getConfiguration().get("mapreduce.carbontable.load.model");
+    jobContext.getJobConf().set(JobConf.MAPRED_MAP_TASK_ENV,
+        a + ",carbon=" + loadModelStr);
+    jobContext.getJobConf().set(JobConf.MAPRED_REDUCE_TASK_ENV,
+        a + ",carbon=" + loadModelStr);
+  }
+
+  @Override
+  public void setupTask(TaskAttemptContext taskAttemptContext) throws IOException {
+
+  }
+
+  @Override
+  public boolean needsTaskCommit(TaskAttemptContext taskAttemptContext) throws IOException {
+    return false;
+  }
+
+  @Override
+  public void commitTask(TaskAttemptContext taskAttemptContext) throws IOException {
+
+  }
+
+  @Override
+  public void abortTask(TaskAttemptContext taskAttemptContext) throws IOException {
+
+  }
+
+  @Override
+  public void abortJob(JobContext jobContext, int status) throws IOException {
+    if (carbonOutputCommitter != null) {
+      carbonOutputCommitter.abortJob(jobContext, JobStatus.State.FAILED);
+      throw new RuntimeException("Failed to commit Job");
+    }
+  }
+
+  @Override
+  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(),
 
 Review comment:
   So, for nonntransactional also we write segment files now ?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services