[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-29 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/carbondata/pull/1094


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-28 Thread mayunSaicmotor
Github user mayunSaicmotor commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r124582318
  
--- Diff: 
examples/spark/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
 ---
@@ -0,0 +1,128 @@
+/*
+ * 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.examples
+
+import scala.collection.mutable.LinkedHashMap
+
+import org.apache.spark.sql.AnalysisException
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.util.CarbonProperties
+import org.apache.carbondata.examples.util.ExampleUtils
+
+object CarbonPartitionExample {
--- End diff --

actually there are some creating partition table and showing partitions 
code in it, do you mean delete  the showing partition code and keep creating 
partition table code?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-27 Thread gvramana
Github user gvramana commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r124451853
  
--- Diff: 
examples/spark/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
 ---
@@ -114,14 +104,43 @@ object CarbonPartitionExample {
 | STORED BY 'carbondata'
 | 
TBLPROPERTIES('PARTITION_TYPE'='HASH','NUM_PARTITIONS'='5')
 """.stripMargin)
-cc.sql(s"""SHOW PARTITIONS partitionDB.$tableName""").show()
-cc.sql(s"""SHOW PARTITIONS $tableName""").show()
+// hive partition table
--- End diff --

We dont need to give example of hive partion table in carbon examples.
Testcase can be added to check if hive parition table show is not impacted.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-27 Thread gvramana
Github user gvramana commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r124226416
  
--- Diff: 
integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
 ---
@@ -544,4 +552,52 @@ object CommonUtil {
 }
   }
 
+  def getPartitionInfo(columnName: String, partitionType: PartitionType,
+  partitionInfo: PartitionInfo): Seq[Row] = {
+var result = Seq.newBuilder[Row]
+partitionType match {
+  case PartitionType.RANGE =>
+result.+=(RowFactory.create(columnName + "=default"))
+var rangeInfo = partitionInfo.getRangeInfo
+var size = rangeInfo.size() - 1
+for (index <- 0 to size) {
+  if (index == 0) {
+result.+=(RowFactory.create(columnName + "<" + 
rangeInfo.get(index)))
+  } else {
+result.+=(RowFactory.create(rangeInfo.get(index - 1) + "<=" +
+  columnName + "<" + rangeInfo.get(index)))
+  }
+}
+  case PartitionType.RANGE_INTERVAL =>
+result.+=(RowFactory.create(columnName + "="))
+  case PartitionType.LIST =>
+result.+=(RowFactory.create(columnName + "=default"))
+var id = 1
+var listInfo = partitionInfo.getListInfo
+var size = listInfo.size() - 1
+for (index <- 0 to size) {
+  var listStr = ""
+  listInfo.get(index).toArray().foreach { x =>
--- End diff --

Please use map/foreach function and inside use mkString(",") function


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-27 Thread gvramana
Github user gvramana commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r124225277
  
--- Diff: 
examples/spark/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
 ---
@@ -0,0 +1,128 @@
+/*
+ * 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.examples
+
+import scala.collection.mutable.LinkedHashMap
+
+import org.apache.spark.sql.AnalysisException
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.util.CarbonProperties
+import org.apache.carbondata.examples.util.ExampleUtils
+
+object CarbonPartitionExample {
--- End diff --

Examples are used for uses to explain all the key features. Need not add 
examples for sub feature. Please update the partition Example adding show 
paritions ddl.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-27 Thread mayunSaicmotor
Github user mayunSaicmotor commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r124206197
  
--- Diff: 
examples/spark/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
 ---
@@ -0,0 +1,128 @@
+/*
+ * 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.examples
+
+import scala.collection.mutable.LinkedHashMap
+
+import org.apache.spark.sql.AnalysisException
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.util.CarbonProperties
+import org.apache.carbondata.examples.util.ExampleUtils
+
+object CarbonPartitionExample {
--- End diff --

do you mean  delete this class? actually it is convenient for users  to 
take a look  “show partition” result on spark1.6 and for me as a dev user, 
I can use it to test and debug


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-27 Thread mayunSaicmotor
Github user mayunSaicmotor commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r124204888
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/DDLStrategy.scala
 ---
@@ -117,6 +117,8 @@ class DDLStrategy(sparkSession: SparkSession) extends 
SparkStrategy {
   
sparkSession.sessionState.executePlan(UnresolvedRelation(identifier, 
None)).analyzed
 val resultPlan = 
sparkSession.sessionState.executePlan(resolvedTable).executedPlan
 ExecutedCommandExec(DescribeCommandFormatted(resultPlan, 
plan.output, identifier)) :: Nil
+  case ShowPartitionsCommand(t, cols) =>
+ExecutedCommandExec(ShowCarbonPartitionsCommand(t)) :: Nil
--- End diff --

fixed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-27 Thread mayunSaicmotor
Github user mayunSaicmotor commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r124204837
  
--- Diff: 
examples/spark/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
 ---
@@ -0,0 +1,128 @@
+/*
+ * 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.examples
+
+import scala.collection.mutable.LinkedHashMap
+
+import org.apache.spark.sql.AnalysisException
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.util.CarbonProperties
+import org.apache.carbondata.examples.util.ExampleUtils
+
+object CarbonPartitionExample {
+  def main(args: Array[String]) {
+CarbonPartitionExample.extracted("t3", args)
+  }
+  def extracted(tableName: String, args: Array[String]): Unit = {
+val cc = ExampleUtils.createCarbonContext("CarbonPartitionExample")
+val testData = ExampleUtils.currentPath + 
"/src/main/resources/data.csv"
+CarbonProperties.getInstance()
+  .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, 
"/MM/dd")
+
+// none partition table
+cc.sql("DROP TABLE IF EXISTS t0")
+cc.sql("""
+| CREATE TABLE IF NOT EXISTS t0
+| (
+| vin String,
+| logdate Timestamp,
+| phonenumber Int,
+| country String,
+| area String
+| )
+| STORED BY 'carbondata'
+  """.stripMargin)
+try {
+  cc.sql("""SHOW PARTITIONS t0""").show()
+} catch {
+  case ex: AnalysisException => print(ex.getMessage())
+}
+
+// range partition
+cc.sql("DROP TABLE IF EXISTS t1")
+cc.sql("""
+| CREATE TABLE IF NOT EXISTS t1(
+| vin STRING,
+| phonenumber INT,
+| country STRING,
+| area STRING
+| )
+| PARTITIONED BY (logdate TIMESTAMP)
+| STORED BY 'carbondata'
+| TBLPROPERTIES('PARTITION_TYPE'='RANGE',
+| 'RANGE_INFO'='2014/01/01,2015/01/01,2016/01/01')
+  """.stripMargin)
+cc.sql("""SHOW PARTITIONS t1""").show()
+
+// hash partition
+cc.sql("""
+| CREATE TABLE IF NOT EXISTS t3(
+| logdate Timestamp,
+| phonenumber Int,
+| country String,
+| area String
+| )
+| PARTITIONED BY (vin String)
+| STORED BY 'carbondata'
+| 
TBLPROPERTIES('PARTITION_TYPE'='HASH','NUM_PARTITIONS'='5')
+""".stripMargin)
+cc.sql("""SHOW PARTITIONS t3""").show()
+
+// list partition
+cc.sql("DROP TABLE IF EXISTS t5")
+cc.sql("""
+   | CREATE TABLE IF NOT EXISTS t5(
+   | vin String,
+   | logdate Timestamp,
+   | phonenumber Int,
+   | area String
+   | )
+   | PARTITIONED BY (country string)
+   | STORED BY 'carbondata'
+   | TBLPROPERTIES('PARTITION_TYPE'='LIST',
+   | 'LIST_INFO'='(China,United States),UK 
,japan,(Canada,Russia), South Korea ')
+   """.stripMargin)
+cc.sql("""SHOW PARTITIONS t5""").show()
+
+cc.sql(s"DROP TABLE IF EXISTS partitionDB.$tableName")
--- End diff --

fixed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-26 Thread kunal642
Github user kunal642 commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r123987924
  
--- Diff: 
integration/spark/src/main/scala/org/apache/spark/sql/execution/command/ShowCarbonPartitionsCommand.scala
 ---
@@ -0,0 +1,51 @@
+/*
+ * 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
+
+import org.apache.spark.sql._
+import org.apache.spark.sql.catalyst.TableIdentifier
+import org.apache.spark.sql.catalyst.expressions.{Attribute, 
AttributeReference}
+import org.apache.spark.sql.execution.RunnableCommand
+import org.apache.spark.sql.types._
+
+import org.apache.carbondata.common.logging.LogServiceFactory
+import org.apache.carbondata.spark.util.CommonUtil
+
+private[sql] case class ShowCarbonPartitionsCommand(
--- End diff --

Move this case class to carbonTableSchema


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-26 Thread kunal642
Github user kunal642 commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r123987965
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/ShowCarbonPartitionsCommand.scala
 ---
@@ -0,0 +1,52 @@
+/*
+ * 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
+
+import org.apache.spark.sql.AnalysisException
+import org.apache.spark.sql.CarbonEnv
+import org.apache.spark.sql.catalyst.TableIdentifier
+import org.apache.spark.sql.hive.CarbonRelation
+import org.apache.spark.sql.Row
+import org.apache.spark.sql.SparkSession
+
+import org.apache.carbondata.common.logging.LogServiceFactory
+import org.apache.carbondata.spark.util.CommonUtil
+
+private[sql] case class ShowCarbonPartitionsCommand(
--- End diff --

Move to carbonTableScheam


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-26 Thread kunal642
Github user kunal642 commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r123987774
  
--- Diff: 
integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestShowPartitions.scala
 ---
@@ -0,0 +1,188 @@
+/*
+ * 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.spark.testsuite.partition
+
+import java.sql.Timestamp
+
+import org.apache.spark.sql.AnalysisException
+import org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException
+import org.apache.spark.sql.Row
+import org.apache.spark.sql.common.util.QueryTest
+import org.scalatest.BeforeAndAfterAll
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.util.CarbonProperties
+
+
+
+class TestShowPartition  extends QueryTest with BeforeAndAfterAll {
+  override def beforeAll = {
+
+CarbonProperties.getInstance()
+  .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, 
"dd-MM-")
+
+sql("drop table if exists notPartitionTable")
+sql("""
+| CREATE TABLE notPartitionTable
+| (
+| vin String,
+| logdate Timestamp,
+| phonenumber Int,
+| country String,
+| area String
+| )
+| STORED BY 'carbondata'
+  """.stripMargin)
+
+sql("drop table if exists hashTable")
+sql(
+  """
+| CREATE TABLE hashTable (empname String, designation String, doj 
Timestamp,
+|  workgroupcategory int, workgroupcategoryname String, deptno 
int, deptname String,
+|  projectcode int, projectjoindate Timestamp, projectenddate 
Timestamp,attendance int,
+|  utilization int,salary int)
+| PARTITIONED BY (empno int)
+| STORED BY 'org.apache.carbondata.format'
+| TBLPROPERTIES('PARTITION_TYPE'='HASH','NUM_PARTITIONS'='3')
+  """.stripMargin)
+
+sql("drop table if exists rangeTable")
+sql(
+  """
+| CREATE TABLE rangeTable (empno int, empname String, designation 
String,
+|  workgroupcategory int, workgroupcategoryname String, deptno 
int, deptname String,
+|  projectcode int, projectjoindate Timestamp, projectenddate 
Timestamp,attendance int,
+|  utilization int,salary int)
+| PARTITIONED BY (doj Timestamp)
+| STORED BY 'org.apache.carbondata.format'
+| TBLPROPERTIES('PARTITION_TYPE'='RANGE',
+|  'RANGE_INFO'='01-01-2010, 01-01-2015')
+  """.stripMargin)
+
+sql("drop table if exists listTable")
+sql(
+  """
+| CREATE TABLE listTable (empno int, empname String, designation 
String, doj Timestamp,
+|  workgroupcategoryname String, deptno int, deptname String,
+|  projectcode int, projectjoindate Timestamp, projectenddate 
Timestamp,attendance int,
+|  utilization int,salary int)
+| PARTITIONED BY (workgroupcategory int)
+| STORED BY 'org.apache.carbondata.format'
+| TBLPROPERTIES('PARTITION_TYPE'='LIST',
+|  'LIST_INFO'='0, 1, (2, 3)')
+  """.stripMargin)
+
+sql(s"CREATE DATABASE if not exists partitionDB")
+sql("drop table if exists partitionDB.hashTable")
+sql("drop table if exists partitionDB.rangeTable")
+sql("drop table if exists partitionDB.listTable")
+sql(
+  """
+| CREATE TABLE partitionDB.hashTable (empname String, designation 
String, doj Timestamp,
+|  workgroupcategory int, workgroupcategoryname String, deptno 
int, deptname String,
+|  projectcode int, projectjoindate Timestamp, projectenddate 
Timestamp,attendance int,
+|  utilization int,salary int)
+| PARTITIONED BY (empno int)
+| STOR

[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-26 Thread kunal642
Github user kunal642 commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r123987699
  
--- Diff: 
examples/spark/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
 ---
@@ -0,0 +1,128 @@
+/*
+ * 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.examples
+
+import scala.collection.mutable.LinkedHashMap
+
+import org.apache.spark.sql.AnalysisException
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.util.CarbonProperties
+import org.apache.carbondata.examples.util.ExampleUtils
+
+object CarbonPartitionExample {
--- End diff --

No need to add seperate Example class for Partitions.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-25 Thread chenerlu
Github user chenerlu commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r123894295
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/DDLStrategy.scala
 ---
@@ -117,6 +117,8 @@ class DDLStrategy(sparkSession: SparkSession) extends 
SparkStrategy {
   
sparkSession.sessionState.executePlan(UnresolvedRelation(identifier, 
None)).analyzed
 val resultPlan = 
sparkSession.sessionState.executePlan(resolvedTable).executedPlan
 ExecutedCommandExec(DescribeCommandFormatted(resultPlan, 
plan.output, identifier)) :: Nil
+  case ShowPartitionsCommand(t, cols) =>
+ExecutedCommandExec(ShowCarbonPartitionsCommand(t)) :: Nil
--- End diff --

Test the  compatible with hive partition table.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-25 Thread chenerlu
Github user chenerlu commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r123893089
  
--- Diff: 
examples/spark/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
 ---
@@ -0,0 +1,128 @@
+/*
+ * 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.examples
+
+import scala.collection.mutable.LinkedHashMap
+
+import org.apache.spark.sql.AnalysisException
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.util.CarbonProperties
+import org.apache.carbondata.examples.util.ExampleUtils
+
+object CarbonPartitionExample {
+  def main(args: Array[String]) {
+CarbonPartitionExample.extracted("t3", args)
+  }
+  def extracted(tableName: String, args: Array[String]): Unit = {
+val cc = ExampleUtils.createCarbonContext("CarbonPartitionExample")
+val testData = ExampleUtils.currentPath + 
"/src/main/resources/data.csv"
+CarbonProperties.getInstance()
+  .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, 
"/MM/dd")
+
+// none partition table
+cc.sql("DROP TABLE IF EXISTS t0")
+cc.sql("""
+| CREATE TABLE IF NOT EXISTS t0
+| (
+| vin String,
+| logdate Timestamp,
+| phonenumber Int,
+| country String,
+| area String
+| )
+| STORED BY 'carbondata'
+  """.stripMargin)
+try {
+  cc.sql("""SHOW PARTITIONS t0""").show()
+} catch {
+  case ex: AnalysisException => print(ex.getMessage())
+}
+
+// range partition
+cc.sql("DROP TABLE IF EXISTS t1")
+cc.sql("""
+| CREATE TABLE IF NOT EXISTS t1(
+| vin STRING,
+| phonenumber INT,
+| country STRING,
+| area STRING
+| )
+| PARTITIONED BY (logdate TIMESTAMP)
+| STORED BY 'carbondata'
+| TBLPROPERTIES('PARTITION_TYPE'='RANGE',
+| 'RANGE_INFO'='2014/01/01,2015/01/01,2016/01/01')
+  """.stripMargin)
+cc.sql("""SHOW PARTITIONS t1""").show()
+
+// hash partition
+cc.sql("""
+| CREATE TABLE IF NOT EXISTS t3(
+| logdate Timestamp,
+| phonenumber Int,
+| country String,
+| area String
+| )
+| PARTITIONED BY (vin String)
+| STORED BY 'carbondata'
+| 
TBLPROPERTIES('PARTITION_TYPE'='HASH','NUM_PARTITIONS'='5')
+""".stripMargin)
+cc.sql("""SHOW PARTITIONS t3""").show()
+
+// list partition
+cc.sql("DROP TABLE IF EXISTS t5")
+cc.sql("""
+   | CREATE TABLE IF NOT EXISTS t5(
+   | vin String,
+   | logdate Timestamp,
+   | phonenumber Int,
+   | area String
+   | )
+   | PARTITIONED BY (country string)
+   | STORED BY 'carbondata'
+   | TBLPROPERTIES('PARTITION_TYPE'='LIST',
+   | 'LIST_INFO'='(China,United States),UK 
,japan,(Canada,Russia), South Korea ')
+   """.stripMargin)
+cc.sql("""SHOW PARTITIONS t5""").show()
+
+cc.sql(s"DROP TABLE IF EXISTS partitionDB.$tableName")
--- End diff --

I think $tableName is not proper.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-25 Thread chenerlu
Github user chenerlu commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1094#discussion_r123893046
  
--- Diff: 
examples/spark/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
 ---
@@ -0,0 +1,128 @@
+/*
+ * 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.examples
+
+import scala.collection.mutable.LinkedHashMap
+
+import org.apache.spark.sql.AnalysisException
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.util.CarbonProperties
+import org.apache.carbondata.examples.util.ExampleUtils
+
+object CarbonPartitionExample {
+  def main(args: Array[String]) {
+CarbonPartitionExample.extracted("t3", args)
+  }
+  def extracted(tableName: String, args: Array[String]): Unit = {
+val cc = ExampleUtils.createCarbonContext("CarbonPartitionExample")
+val testData = ExampleUtils.currentPath + 
"/src/main/resources/data.csv"
+CarbonProperties.getInstance()
+  .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, 
"/MM/dd")
+
+// none partition table
+cc.sql("DROP TABLE IF EXISTS t0")
+cc.sql("""
+| CREATE TABLE IF NOT EXISTS t0
+| (
+| vin String,
+| logdate Timestamp,
+| phonenumber Int,
+| country String,
+| area String
+| )
+| STORED BY 'carbondata'
+  """.stripMargin)
+try {
+  cc.sql("""SHOW PARTITIONS t0""").show()
+} catch {
+  case ex: AnalysisException => print(ex.getMessage())
+}
--- End diff --

Why use try catch ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] carbondata pull request #1094: [CARBONDATA-1181] Show partitions

2017-06-24 Thread mayunSaicmotor
GitHub user mayunSaicmotor opened a pull request:

https://github.com/apache/carbondata/pull/1094

[CARBONDATA-1181] Show partitions

Show table partition information

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/mayunSaicmotor/incubator-carbondata 
SHOW-PARTITION

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/carbondata/pull/1094.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1094


commit e41b983ab07c01449d9e1d43f694a2f87d6c90bc
Author: mayun 
Date:   2017-06-25T04:12:06Z

show partition function




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---