[GitHub] [carbondata] QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] Optimize Carbon SparkExtensions

2020-01-19 Thread GitBox
QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] 
Optimize Carbon SparkExtensions
URL: https://github.com/apache/carbondata/pull/3574#discussion_r368291356
 
 

 ##
 File path: 
core/src/main/java/org/apache/carbondata/core/statusmanager/SegmentStatusManager.java
 ##
 @@ -1100,6 +1101,62 @@ public static void 
deleteLoadsAndUpdateMetadata(CarbonTable carbonTable, boolean
 }
   }
 
+  public static void truncateTable(CarbonTable carbonTable)
+  throws ConcurrentOperationException, IOException {
+ICarbonLock carbonTableStatusLock = CarbonLockFactory.getCarbonLockObj(
+carbonTable.getAbsoluteTableIdentifier(), LockUsage.TABLE_STATUS_LOCK);
+boolean locked = false;
+try {
+  // Update load metadate file after cleaning deleted nodes
+  locked = carbonTableStatusLock.lockWithRetries();
+  if (locked) {
+LOG.info("Table status lock has been successfully acquired.");
+LoadMetadataDetails[] listOfLoadFolderDetailsArray =
+SegmentStatusManager.readLoadMetadata(
+CarbonTablePath.getMetadataPath(carbonTable.getTablePath()));
+for (LoadMetadataDetails listOfLoadFolderDetails : 
listOfLoadFolderDetailsArray) {
+  boolean writing;
+  switch (listOfLoadFolderDetails.getSegmentStatus()) {
+case INSERT_IN_PROGRESS:
+  writing = true;
+  break;
+case INSERT_OVERWRITE_IN_PROGRESS:
+  writing = true;
+  break;
+case STREAMING:
+  writing = true;
+  break;
+default:
+  writing = false;
+  }
+  if (writing) {
+throw new ConcurrentOperationException(carbonTable, "insert", 
"truncate");
+  }
+}
 
 Review comment:
   fixed


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


With regards,
Apache Git Services


[GitHub] [carbondata] QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] Optimize Carbon SparkExtensions

2020-01-17 Thread GitBox
QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] 
Optimize Carbon SparkExtensions
URL: https://github.com/apache/carbondata/pull/3574#discussion_r367890907
 
 

 ##
 File path: 
integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonExtensionSpark2SqlParser.scala
 ##
 @@ -0,0 +1,162 @@
+/*
+ * 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.parser
+
+import scala.language.implicitConversions
+
+import org.apache.spark.sql.catalyst.plans.logical._
+import org.apache.spark.sql.catalyst.CarbonParserUtil
+import org.apache.spark.sql.execution.command._
+import org.apache.spark.sql.execution.command.management.CarbonLoadDataCommand
+import 
org.apache.spark.sql.execution.command.schema.{CarbonAlterTableAddColumnCommand,
 CarbonAlterTableColRenameDataTypeChangeCommand, 
CarbonAlterTableDropColumnCommand}
+
+import 
org.apache.carbondata.common.exceptions.sql.MalformedCarbonCommandException
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+
+/**
+ * TODO remove the duplicate code and add the common methods to common class.
 
 Review comment:
   done, already refactory


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


With regards,
Apache Git Services


[GitHub] [carbondata] QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] Optimize Carbon SparkExtensions

2020-01-17 Thread GitBox
QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] 
Optimize Carbon SparkExtensions
URL: https://github.com/apache/carbondata/pull/3574#discussion_r367884022
 
 

 ##
 File path: 
core/src/main/java/org/apache/carbondata/core/metadata/schema/table/DatabaseDMSchemaStorageProvider.java
 ##
 @@ -0,0 +1,59 @@
+/*
+ * 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.core.metadata.schema.table;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.carbondata.common.exceptions.sql.NoSuchDataMapException;
+
+/**
+ * Stores datamap schema in database
+ */
+public class DatabaseDMSchemaStorageProvider implements 
DataMapSchemaStorageProvider {
 
 Review comment:
   yes, now it is an interface only, but we can implement it in the future


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


With regards,
Apache Git Services


[GitHub] [carbondata] QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] Optimize Carbon SparkExtensions

2020-01-17 Thread GitBox
QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] 
Optimize Carbon SparkExtensions
URL: https://github.com/apache/carbondata/pull/3574#discussion_r367883785
 
 

 ##
 File path: 
core/src/main/java/org/apache/carbondata/core/metadata/DatabaseLocationProvider.java
 ##
 @@ -0,0 +1,61 @@
+/*
+ * 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.core.metadata;
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
+import org.apache.carbondata.core.util.CarbonProperties;
+
+public abstract class DatabaseLocationProvider {
 
 Review comment:
   done 
   support converting database name to session-related name


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


With regards,
Apache Git Services


[GitHub] [carbondata] QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] Optimize Carbon SparkExtensions

2020-01-17 Thread GitBox
QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] 
Optimize Carbon SparkExtensions
URL: https://github.com/apache/carbondata/pull/3574#discussion_r367881938
 
 

 ##
 File path: 
core/src/main/java/org/apache/carbondata/core/constants/CarbonCommonConstants.java
 ##
 @@ -191,6 +191,12 @@ private CarbonCommonConstants() {
 
   public static final String LOCK_PATH_DEFAULT = "";
 
+  /**
+   * Specifies the lock implement class.
 
 Review comment:
   done, the class should be the implement of ICarbonLock


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


With regards,
Apache Git Services


[GitHub] [carbondata] QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] Optimize Carbon SparkExtensions

2020-01-17 Thread GitBox
QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] 
Optimize Carbon SparkExtensions
URL: https://github.com/apache/carbondata/pull/3574#discussion_r367880746
 
 

 ##
 File path: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonCreateTableCommand.scala
 ##
 @@ -140,11 +140,31 @@ case class CarbonCreateTableCommand(
   s"Dictionary include cannot be applied on partition columns")
   }
   s" PARTITIONED BY 
(${partitionInfo.getColumnSchemaList.asScala.map(
-_.getColumnName).mkString(",")})"
+_.getColumnName.toLowerCase).mkString(",")})"
 } else {
   ""
 }
 
+  val repeatedPropKeys =
 
 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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [carbondata] QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] Optimize Carbon SparkExtensions

2020-01-17 Thread GitBox
QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] 
Optimize Carbon SparkExtensions
URL: https://github.com/apache/carbondata/pull/3574#discussion_r367879348
 
 

 ##
 File path: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonExplainCommand.scala
 ##
 @@ -42,16 +43,37 @@ case class CarbonExplainCommand(
 if (explainCommand.logicalPlan.isStreaming || isCommand) {
   explainCommand.run(sparkSession)
 } else {
-  collectProfiler(sparkSession) ++ explainCommand.run(sparkSession)
+  CarbonExplainCommand.collectProfiler(explainCommand, sparkSession) ++
+  explainCommand.run(sparkSession)
 }
   }
 
-  private def collectProfiler(sparkSession: SparkSession): Seq[Row] = {
+  override protected def opName: String = "EXPLAIN"
+}
+
+case class CarbonInternalExplainCommand(
 
 Review comment:
   yes, CarbonExtensions will use this command instead of CarbonExplainCommand


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


With regards,
Apache Git Services


[GitHub] [carbondata] QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] Optimize Carbon SparkExtensions

2020-01-17 Thread GitBox
QiangCai commented on a change in pull request #3574: [CARBONDATA-3503] 
Optimize Carbon SparkExtensions
URL: https://github.com/apache/carbondata/pull/3574#discussion_r367866479
 
 

 ##
 File path: pom.xml
 ##
 @@ -103,7 +103,6 @@
 integration/spark-datasource
 integration/spark2
 integration/spark-common-test
-integration/spark-carbon-common-test
 
 Review comment:
   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:
us...@infra.apache.org


With regards,
Apache Git Services