[GitHub] carbondata pull request #2800: [CARBONDATA-2595] Reformat the output of comm...

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata pull request #2800: [CARBONDATA-2595] Reformat the output of comm...

qiuchenjian-2
GitHub user zzcclp opened a pull request:

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

    [CARBONDATA-2595] Reformat the output of command 'desc formatted table_name'

    According to the discussion in [topic](http://apache-carbondata-dev-mailing-list-archive.1130556.n5.nabble.com/Change-the-comment-content-for-column-when-execute-command-desc-formatted-table-name-td46848.html) , reformat the output of command 'desc formatted table_name'.
   
    Be sure to do all of the following checklist to help us incorporate
    your contribution quickly and easily:
   
     - [ ] Any interfaces changed? No
     
     - [ ] Any backward compatibility impacted? No
     
     - [ ] Document update required? No
   
     - [ ] Testing done
            Please provide details on
            - Whether new unit test cases have been added or why no new tests are required?
            - How it is tested? Please attach test report.
            - Is it a performance related change? Please attach the performance test report.
            - Any additional information to help reviewers in testing this change.
           
     - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.
   


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

    $ git pull https://github.com/zzcclp/carbondata CARBONDATA-2595

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

    https://github.com/apache/carbondata/pull/2800.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 #2800
   
----
commit 9c243f1a496361dd949b0239622b0da9f3310f99
Author: Zhang Zhichao <441586683@...>
Date:   2018-10-06T08:40:44Z

    [CARBONDATA-2595] Reformat the output of command 'desc formatted table_name'
   
    According to the discussion in http://apache-carbondata-dev-mailing-list-archive.1130556.n5.nabble.com/Change-the-comment-content-for-column-when-execute-command-desc-formatted-table-name-td46848.html, reformat the output of command 'desc formatted table_name'.

----


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata issue #2800: [CARBONDATA-2595] Reformat the output of command 'de...

qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2800
 
    Build Failed  with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder2.1/730/



---
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata issue #2800: [CARBONDATA-2595] Reformat the output of command 'de...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2800
 
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder2.1/731/



---
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata issue #2800: [CARBONDATA-2595] Reformat the output of command 'de...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2800
 
    Build Failed  with Spark 2.3.1, Please check CI http://136.243.101.176:8080/job/carbondataprbuilder2.3/8996/



---
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata issue #2800: [CARBONDATA-2595] Reformat the output of command 'de...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2800
 
    Build Failed with Spark 2.2.1, Please check CI http://95.216.28.178:8080/job/ApacheCarbonPRBuilder1/928/



---
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata issue #2800: [CARBONDATA-2595] Reformat the output of command 'de...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2800
 
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder2.1/732/



---
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata issue #2800: [CARBONDATA-2595] Reformat the output of command 'de...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2800
 
    Build Success with Spark 2.3.1, Please check CI http://136.243.101.176:8080/job/carbondataprbuilder2.3/8997/



---
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata issue #2800: [CARBONDATA-2595] Reformat the output of command 'de...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2800
 
    Build Success with Spark 2.2.1, Please check CI http://95.216.28.178:8080/job/ApacheCarbonPRBuilder1/929/



---
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata issue #2800: [CARBONDATA-2595] Reformat the output of command 'de...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user zzcclp commented on the issue:

    https://github.com/apache/carbondata/pull/2800
 
    @jackylk @chenliang613 please review.


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata pull request #2800: [CARBONDATA-2595] Reformat the output of comm...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/2800#discussion_r223205791
 
    --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonDescribeFormattedCommand.scala ---
    @@ -44,89 +42,121 @@ private[sql] case class CarbonDescribeFormattedCommand(
       override def processMetadata(sparkSession: SparkSession): Seq[Row] = {
         val relation = CarbonEnv.getInstance(sparkSession).carbonMetastore
           .lookupRelation(tblIdentifier)(sparkSession).asInstanceOf[CarbonRelation]
    -    val mapper = new ObjectMapper()
    -    val colProps = StringBuilder.newBuilder
    -    val dims = relation.metaData.dims.map(x => x.toLowerCase)
    -    var results: Seq[(String, String, String)] = child.schema.fields.map { field =>
    -      val fieldName = field.name.toLowerCase
    -      val colComment = field.getComment().getOrElse("null")
    -      val comment = if (dims.contains(fieldName)) {
    -        val dimension = relation.metaData.carbonTable.getDimensionByName(
    -          relation.carbonTable.getTableName, fieldName)
    -        if (null != dimension.getColumnProperties && !dimension.getColumnProperties.isEmpty) {
    -          colProps.append(fieldName).append(".")
    -            .append(mapper.writeValueAsString(dimension.getColumnProperties))
    -            .append(",")
    -        }
    -        if (dimension.hasEncoding(Encoding.DICTIONARY) &&
    -            !dimension.hasEncoding(Encoding.DIRECT_DICTIONARY)) {
    -          "DICTIONARY, KEY COLUMN" + (if (dimension.hasEncoding(Encoding.INVERTED_INDEX)) {
    -            "".concat(",").concat(colComment)
    -          } else {
    -            ",NOINVERTEDINDEX".concat(",").concat(colComment)
    -          })
    -        } else {
    -          "KEY COLUMN" + (if (dimension.hasEncoding(Encoding.INVERTED_INDEX)) {
    -            "".concat(",").concat(colComment)
    -          } else {
    -            ",NOINVERTEDINDEX".concat(",").concat(colComment)
    -          })
    -        }
    -      } else {
    -        "MEASURE".concat(",").concat(colComment)
    -      }
    +    val carbonTable = relation.carbonTable
    +    val tblProps = carbonTable.getTableInfo.getFactTable.getTableProperties
     
    -      (field.name, field.dataType.simpleString, comment)
    -    }
    -    val colPropStr = if (colProps.toString().trim().length() > 0) {
    -      // drops additional comma at end
    -      colProps.toString().dropRight(1)
    -    } else {
    -      colProps.toString()
    +    // Table Schema Information
    +    var results: Seq[(String, String, String)] = child.schema.fields.map { field =>
    +      (field.name, field.dataType.simpleString, field.getComment().getOrElse(""))
         }
    -    val carbonTable = relation.carbonTable
    -    results ++= Seq(("", "", ""), ("##Detailed Table Information", "", ""))
    -    results ++= Seq(("Database Name", relation.carbonTable.getDatabaseName, "")
    -    )
    -    results ++= Seq(("Table Name", relation.carbonTable.getTableName, ""))
    -    results ++= Seq(("CARBON Store Path ", carbonTable.getTablePath, ""))
     
    -    val tblProps = carbonTable.getTableInfo.getFactTable.getTableProperties
    +    results ++= Seq(("", "", ""), ("### PROPERTY", "VALUE", "DEFAULT_VALUE"))
    +
    +    // Table Basic Information
    +    results ++= Seq(("", "", ""), ("## Table Basic Information", "", ""))
    +    results ++= Seq(("Database Name", carbonTable.getDatabaseName, ""))
    +    results ++= Seq(("Table Name", carbonTable.getTableName, ""))
    +    results ++= Seq(("Table Path", carbonTable.getTablePath, ""))
     
         // Carbon table support table comment
    -    val tableComment = tblProps.asScala.getOrElse(CarbonCommonConstants.TABLE_COMMENT, "")
    -    results ++= Seq(("Comment", tableComment, ""))
    -    results ++= Seq(("Table Block Size ", carbonTable.getBlockSizeInMB + " MB", ""))
    +    results ++= Seq(("Comment",
    +        tblProps.asScala.getOrElse(CarbonCommonConstants.TABLE_COMMENT, ""), ""))
    +
         val dataIndexSize = CarbonUtil.calculateDataIndexSize(carbonTable, false)
    +    var tableDataSizeStr = "0B"
    +    var tableIndexSizeStr = "0B"
    +    var lastUpdateTimeStr = "NA"
         if (!dataIndexSize.isEmpty) {
    -      results ++= Seq((CarbonCommonConstants.TABLE_DATA_SIZE,
    -        dataIndexSize.get(CarbonCommonConstants.CARBON_TOTAL_DATA_SIZE).toString, ""))
    -      results ++= Seq((CarbonCommonConstants.TABLE_INDEX_SIZE,
    -        dataIndexSize.get(CarbonCommonConstants.CARBON_TOTAL_INDEX_SIZE).toString, ""))
    -      results ++= Seq((CarbonCommonConstants.LAST_UPDATE_TIME,
    -        dataIndexSize.get(CarbonCommonConstants.LAST_UPDATE_TIME).toString, ""))
    +      val tableDataSize =
    +        dataIndexSize.get(CarbonCommonConstants.CARBON_TOTAL_DATA_SIZE).toLong
    +      tableDataSizeStr = Strings.formatSize(tableDataSize)
    +      val tableIndexSize =
    +        dataIndexSize.get(CarbonCommonConstants.CARBON_TOTAL_INDEX_SIZE).toLong
    +      tableIndexSizeStr = Strings.formatSize(tableIndexSize)
    +      val lastUpdateTime = dataIndexSize.get(CarbonCommonConstants.LAST_UPDATE_TIME).toLong
    +      lastUpdateTimeStr = if (lastUpdateTime > 0L) {
    +        new java.sql.Timestamp(lastUpdateTime).toString()
    +      } else {
    +        "NA"
    +      }
         }
    +    results ++= Seq((CarbonCommonConstants.TABLE_DATA_SIZE, tableDataSizeStr, ""))
    +    results ++= Seq((CarbonCommonConstants.TABLE_INDEX_SIZE, tableIndexSizeStr, ""))
    +    results ++= Seq((CarbonCommonConstants.LAST_UPDATE_TIME, lastUpdateTimeStr, ""))
     
    +    // Detailed Table Properties Information
    +    results ++= Seq(("", "", ""), ("## Detailed Table Properties Information", "", ""))
    +    results ++= Seq(("Table Block Size", carbonTable.getBlockSizeInMB + " MB",
    +        CarbonCommonConstants.BLOCK_SIZE_DEFAULT_VAL + " MB"))
         results ++= Seq(("SORT_SCOPE", tblProps.asScala.getOrElse("sort_scope", CarbonCommonConstants
    --- End diff --
   
    For these table properties, I think it is not very good to print the default value if the user does not specify. Because the default value may change from version to version, I think it is better to write the value to table property when loading the table. Then in DESC table, we can always get the table properties from the schema file


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata issue #2800: [CARBONDATA-2595] Reformat the output of command 'de...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Reply | Threaded
Open this post in threaded view
|

[GitHub] carbondata pull request #2800: [CARBONDATA-2595] Reformat the output of comm...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user zzcclp closed the pull request at:

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


---