Github user chenerlu commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r122864076 --- Diff: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/ShowPartitionsCommand.scala --- @@ -0,0 +1,95 @@ +/* + * 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 java.util + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql._ +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.execution.RunnableCommand +import org.apache.spark.sql.types._ + +import org.apache.carbondata.common.logging.LogServiceFactory +import org.apache.carbondata.core.metadata.schema.partition.PartitionType + + +private[sql] case class ShowCarbonPartitionsCommand( + tableIdentifier: TableIdentifier) extends RunnableCommand { + val LOGGER = LogServiceFactory.getLogService(ShowCarbonPartitionsCommand.getClass.getName) + var columnName = "" + override val output: Seq[Attribute] = Seq( + // Column names are based on Hive. + AttributeReference("ID", StringType, nullable = false, + new MetadataBuilder().putString("comment", "partition id").build())(), + AttributeReference("Name", StringType, nullable = false, + new MetadataBuilder().putString("comment", "partition name").build())(), + AttributeReference("Value(" + columnName + "=)", StringType, nullable = true, + new MetadataBuilder().putString("comment", "partition value").build())() + ) + override def run(sqlContext: SQLContext): Seq[Row] = { --- End diff -- Suggest use case match for different partition type --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user chenerlu commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r122864102 --- Diff: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/ShowPartitionsCommand.scala --- @@ -0,0 +1,95 @@ +/* + * 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 java.util + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql._ +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.execution.RunnableCommand +import org.apache.spark.sql.types._ + +import org.apache.carbondata.common.logging.LogServiceFactory +import org.apache.carbondata.core.metadata.schema.partition.PartitionType + + +private[sql] case class ShowCarbonPartitionsCommand( + tableIdentifier: TableIdentifier) extends RunnableCommand { + val LOGGER = LogServiceFactory.getLogService(ShowCarbonPartitionsCommand.getClass.getName) + var columnName = "" + override val output: Seq[Attribute] = Seq( + // Column names are based on Hive. + AttributeReference("ID", StringType, nullable = false, + new MetadataBuilder().putString("comment", "partition id").build())(), + AttributeReference("Name", StringType, nullable = false, + new MetadataBuilder().putString("comment", "partition name").build())(), + AttributeReference("Value(" + columnName + "=)", StringType, nullable = true, + new MetadataBuilder().putString("comment", "partition value").build())() + ) + override def run(sqlContext: SQLContext): Seq[Row] = { + val relation = CarbonEnv.get.carbonMetastore + .lookupRelation1(tableIdentifier)(sqlContext). + asInstanceOf[CarbonRelation] + val carbonTable = relation.tableMeta.carbonTable + var partitionInfo = carbonTable.getPartitionInfo( + carbonTable.getAbsoluteTableIdentifier.getCarbonTableIdentifier.getTableName) + var partitionType = partitionInfo.getPartitionType + var result = Seq.newBuilder[Row] + columnName = partitionInfo.getColumnSchemaList.get(0).getColumnName + if (PartitionType.RANGE.equals(partitionType)) { + result.+=(RowFactory.create("0", "", "default")) + var id = 1 + // var name = "partition_" --- End diff -- delete useless notes. --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user chenerlu commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r122864627 --- Diff: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/ShowPartitionsCommand.scala --- @@ -0,0 +1,95 @@ +/* + * 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 java.util + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql._ +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.execution.RunnableCommand +import org.apache.spark.sql.types._ + +import org.apache.carbondata.common.logging.LogServiceFactory +import org.apache.carbondata.core.metadata.schema.partition.PartitionType + + +private[sql] case class ShowCarbonPartitionsCommand( --- End diff -- Why this class name is different from class name ? Just my doubt. --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:
https://github.com/apache/carbondata/pull/1042 Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/2598/ --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user asfgit commented on the issue:
https://github.com/apache/carbondata/pull/1042 Refer to this link for build results (access rights to CI server needed): https://builds.apache.org/job/carbondata-pr-spark-1.6/500/ --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user chenerlu commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r122896730 --- Diff: examples/spark/src/main/scala/org/apache/carbondata/examples/ShowPartitionInfoExample.scala --- @@ -0,0 +1,108 @@ +/* + * 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.carbondata.core.constants.CarbonCommonConstants +import org.apache.carbondata.core.util.CarbonProperties +import org.apache.carbondata.examples.util.ExampleUtils + +object ShowPartitionInfoExample { + def main(args: Array[String]) { + ShowPartitionInfoExample.extracted("t3", args) + } + def extracted(tableName: String, args: Array[String]): Unit = { + val cc = ExampleUtils.createCarbonContext("CarbonShowPartitionInfo") + val testData = ExampleUtils.currentPath + "/src/main/resources/data.csv" + + // 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') --- End diff -- Better set timestamp format for this. like CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,"yyyy/MM/dd") --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user chenerlu commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r122897255 --- Diff: examples/spark/src/main/scala/org/apache/carbondata/examples/ShowPartitionInfoExample.scala --- @@ -0,0 +1,108 @@ +/* + * 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.carbondata.core.constants.CarbonCommonConstants +import org.apache.carbondata.core.util.CarbonProperties +import org.apache.carbondata.examples.util.ExampleUtils + +object ShowPartitionInfoExample { + def main(args: Array[String]) { + ShowPartitionInfoExample.extracted("t3", args) + } + def extracted(tableName: String, args: Array[String]): Unit = { + val cc = ExampleUtils.createCarbonContext("CarbonShowPartitionInfo") + val testData = ExampleUtils.currentPath + "/src/main/resources/data.csv" + + // range partition + cc.sql("DROP TABLE IF EXISTS t1") + + cc.sql(""" + | CREATE TABLE IF NOT EXISTS t1 + | ( --- End diff -- If you can put "(" after t1, I think it will be better. Still, you can keep your code style. --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user chenerlu commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r122897963 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/ShowCarbonPartitionsCommand.scala --- @@ -0,0 +1,98 @@ +/* + * 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 java.util + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql._ +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.hive.CarbonRelation +import org.apache.spark.sql.types._ + +import org.apache.carbondata.common.logging.LogServiceFactory +import org.apache.carbondata.core.metadata.schema.partition.PartitionType + + + +private[sql] case class ShowCarbonPartitionsCommand( + tableIdentifier: TableIdentifier) extends RunnableCommand { + val LOGGER = LogServiceFactory.getLogService(ShowCarbonPartitionsCommand.getClass.getName) + var columnName = "" + override val output: Seq[Attribute] = Seq( + // Column names are based on Hive. + AttributeReference("ID", StringType, nullable = false, + new MetadataBuilder().putString("comment", "partition id").build())(), + AttributeReference("Name", StringType, nullable = false, --- End diff -- We can reach an agreement for keeping Name or not. --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user asfgit commented on the issue:
https://github.com/apache/carbondata/pull/1042 Refer to this link for build results (access rights to CI server needed): https://builds.apache.org/job/carbondata-pr-spark-1.6/513/ --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:
https://github.com/apache/carbondata/pull/1042 Build Failed with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/2610/ --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user chenliang613 commented on the issue:
https://github.com/apache/carbondata/pull/1042 retest this please --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:
https://github.com/apache/carbondata/pull/1042 Build Failed with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/2643/ --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user asfgit commented on the issue:
https://github.com/apache/carbondata/pull/1042 Refer to this link for build results (access rights to CI server needed): https://builds.apache.org/job/carbondata-pr-spark-1.6/554/ --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r123466148 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/ShowCarbonPartitionsCommand.scala --- @@ -0,0 +1,98 @@ +/* + * 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 java.util + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql._ +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.hive.CarbonRelation +import org.apache.spark.sql.types._ + +import org.apache.carbondata.common.logging.LogServiceFactory +import org.apache.carbondata.core.metadata.schema.partition.PartitionType + + + +private[sql] case class ShowCarbonPartitionsCommand( + tableIdentifier: TableIdentifier) extends RunnableCommand { + val LOGGER = LogServiceFactory.getLogService(ShowCarbonPartitionsCommand.getClass.getName) + var columnName = "" + override val output: Seq[Attribute] = Seq( + // Column names are based on Hive. + AttributeReference("ID", StringType, nullable = false, + new MetadataBuilder().putString("comment", "partition id").build())(), + AttributeReference("Name", StringType, nullable = false, + new MetadataBuilder().putString("comment", "partition name").build())(), + AttributeReference("Value", StringType, nullable = true, + new MetadataBuilder().putString("comment", "partition value").build())() + ) + override def run(sparkSession: SparkSession): Seq[Row] = { --- End diff -- This code is almost same for 1.6 and 2.1. Can you move the common code to CommonUtil --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r123466013 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/hive/CarbonAnalysisRules.scala --- @@ -203,6 +205,7 @@ case class CarbonIUDAnalysisRule(sparkSession: SparkSession) extends Rule[Logica logicalplan transform { case UpdateTable(t, cols, sel, where) => processUpdateQuery(t, cols, sel, where) case DeleteRecords(statement, table) => processDeleteRecordsQuery(statement, table) + case ShowPartitionsCommand(t, cols) => ShowCarbonPartitionsCommand(t) --- End diff -- Not to be handled here --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r123463537 --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/ShowPartitionInfoExample.scala --- @@ -0,0 +1,110 @@ +/* + * 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 java.io.File + +import org.apache.spark.sql.SparkSession + +import org.apache.carbondata.core.constants.CarbonCommonConstants +import org.apache.carbondata.core.util.CarbonProperties + +object ShowPartitionInfoExample { --- End diff -- No need to add a new example. Write one example for "show partition" in CarbonPartitionExample --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r123463416 --- Diff: examples/spark/src/main/scala/org/apache/carbondata/examples/ShowPartitionInfoExample.scala --- @@ -0,0 +1,106 @@ +/* + * 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.carbondata.core.constants.CarbonCommonConstants +import org.apache.carbondata.core.util.CarbonProperties +import org.apache.carbondata.examples.util.ExampleUtils + +object ShowPartitionInfoExample { --- End diff -- No need to add a new example. Write one example for "show partition" in CarbonPartitionExample --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r123464378 --- Diff: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/ShowCarbonPartitionsCommand.scala --- @@ -0,0 +1,95 @@ +/* + * 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 java.util + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql._ +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.execution.RunnableCommand +import org.apache.spark.sql.types._ + +import org.apache.carbondata.common.logging.LogServiceFactory +import org.apache.carbondata.core.metadata.schema.partition.PartitionType + + +private[sql] case class ShowCarbonPartitionsCommand( + tableIdentifier: TableIdentifier) extends RunnableCommand { + val LOGGER = LogServiceFactory.getLogService(ShowCarbonPartitionsCommand.getClass.getName) + var columnName = "" + override val output: Seq[Attribute] = Seq( + // Column names are based on Hive. + AttributeReference("ID", StringType, nullable = false, + new MetadataBuilder().putString("comment", "partition id").build())(), + AttributeReference("Value", StringType, nullable = true, + new MetadataBuilder().putString("comment", "partition value").build())() + ) + override def run(sqlContext: SQLContext): Seq[Row] = { + val relation = CarbonEnv.get.carbonMetastore + .lookupRelation1(tableIdentifier)(sqlContext). + asInstanceOf[CarbonRelation] + val carbonTable = relation.tableMeta.carbonTable + var partitionInfo = carbonTable.getPartitionInfo( --- End diff -- throw an exception if the table is not partitioned --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r123466992 --- Diff: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/ShowCarbonPartitionsCommand.scala --- @@ -0,0 +1,95 @@ +/* + * 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 java.util + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql._ +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.execution.RunnableCommand +import org.apache.spark.sql.types._ + +import org.apache.carbondata.common.logging.LogServiceFactory +import org.apache.carbondata.core.metadata.schema.partition.PartitionType + + +private[sql] case class ShowCarbonPartitionsCommand( + tableIdentifier: TableIdentifier) extends RunnableCommand { + val LOGGER = LogServiceFactory.getLogService(ShowCarbonPartitionsCommand.getClass.getName) + var columnName = "" + override val output: Seq[Attribute] = Seq( + // Column names are based on Hive. + AttributeReference("ID", StringType, nullable = false, + new MetadataBuilder().putString("comment", "partition id").build())(), + AttributeReference("Value", StringType, nullable = true, + new MetadataBuilder().putString("comment", "partition value").build())() + ) + override def run(sqlContext: SQLContext): Seq[Row] = { + val relation = CarbonEnv.get.carbonMetastore + .lookupRelation1(tableIdentifier)(sqlContext). + asInstanceOf[CarbonRelation] + val carbonTable = relation.tableMeta.carbonTable + var partitionInfo = carbonTable.getPartitionInfo( + carbonTable.getAbsoluteTableIdentifier.getCarbonTableIdentifier.getTableName) + var partitionType = partitionInfo.getPartitionType + var result = Seq.newBuilder[Row] + columnName = partitionInfo.getColumnSchemaList.get(0).getColumnName + LOGGER.info("partition column name:" + columnName) + partitionType match { + case PartitionType.RANGE => + result.+=(RowFactory.create("0", "default")) + var id = 1 + var rangeInfo = partitionInfo.getRangeInfo + var size = rangeInfo.size() - 1 + for (index <- 0 to size) { + result.+=(RowFactory.create(id.toString(), "< " + rangeInfo.get(index))) + id += 1 + } + case PartitionType.RANGE_INTERVAL => + result.+=(RowFactory.create("", "")) + case PartitionType.LIST => + result.+=(RowFactory.create("0", "default")) --- End diff -- for list: column_name = 1,3,5,7,10 --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1042#discussion_r123465686 --- Diff: integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonAnalysisRules.scala --- @@ -170,6 +171,7 @@ object CarbonIUDAnalysisRule extends Rule[LogicalPlan] { logicalplan transform { case UpdateTable(t, cols, sel, where) => processUpdateQuery(t, cols, sel, where) case DeleteRecords(statement, table) => processDeleteRecordsQuery(statement, table) + case ShowPartitions(t) => ShowCarbonPartitionsCommand(t) --- End diff -- This should not be here, handle this in DDLStrategy. Spark2 already parses the "show partition" command for us so we can match the same in DDLStrategy. --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
Free forum by Nabble | Edit this page |