Github user kunal642 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1042#discussion_r123466861
  
    --- 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)))
    --- End diff --
    
    can we have the partitions be shown like this for range:
    1<= column_name < 5
    5<= column_name < 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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to