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

    https://github.com/apache/carbondata/pull/1472#discussion_r149587610
  
    --- Diff: 
integration/spark2/src/main/scala/org/apache/spark/util/AlterTableUtil.scala ---
    @@ -317,4 +321,84 @@ object AlterTableUtil {
         }
       }
     
    +  /**
    +   * This method add/modify the table comments.
    +   *
    +   * @param tableIdentifier
    +   * @param properties
    +   * @param propKeys
    +   * @param set
    +   * @param sparkSession
    +   * @param sessionState
    +   */
    +  def modifyTableComment(tableIdentifier: TableIdentifier, properties: 
Map[String, String],
    +                         propKeys: Seq[String], set: Boolean)
    +                        (sparkSession: SparkSession, sessionState: 
CarbonSessionState): Unit = {
    +    val tableName = tableIdentifier.table
    +    val dbName = 
tableIdentifier.database.getOrElse(sparkSession.catalog.currentDatabase)
    +    LOGGER.audit(s"Alter table comment request has been received for 
$dbName.$tableName")
    +    val locksToBeAcquired = List(LockUsage.METADATA_LOCK, 
LockUsage.COMPACTION_LOCK)
    +    var locks = List.empty[ICarbonLock]
    +    var timeStamp = 0L
    +    var newCols = 
Seq[org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema]()
    +    var carbonTable: CarbonTable = null
    +    try {
    +      locks = AlterTableUtil
    +        .validateTableAndAcquireLock(dbName, tableName, 
locksToBeAcquired)(sparkSession)
    +      val metastore = CarbonEnv.getInstance(sparkSession).carbonMetastore
    +      carbonTable = metastore
    +        .lookupRelation(Some(dbName), 
tableName)(sparkSession).asInstanceOf[CarbonRelation]
    +        .tableMeta.carbonTable
    +      // get the latest carbon table
    +      // read the latest schema file
    +      val carbonTablePath = 
CarbonStorePath.getCarbonTablePath(carbonTable.getStorePath,
    +        carbonTable.getCarbonTableIdentifier)
    +      val thriftTableInfo: TableInfo = 
metastore.getThriftTableInfo(carbonTablePath)(sparkSession)
    +      val schemaConverter = new ThriftWrapperSchemaConverterImpl()
    +      val wrapperTableInfo = schemaConverter
    +        .fromExternalToWrapperTableInfo(thriftTableInfo,
    +          dbName,
    +          tableName,
    +          carbonTable.getStorePath)
    +      val schemaEvolutionEntry = new 
org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry
    +      schemaEvolutionEntry.setTimeStamp(timeStamp)
    +      val thriftTable = schemaConverter
    +        .fromWrapperToExternalTableInfo(wrapperTableInfo, dbName, 
tableName)
    +      val tblPropertiesMap: mutable.Map[String, String] =
    +        thriftTable.fact_table.getTableProperties.asScala
    +      if (set) {
    +        //       This overrides old properties and update the comment 
parameter of thriftTable
    +        //       with the newly added/modified comment since thriftTable 
also holds comment as its
    +        //       direct property.
    +
    +        properties.foreach {
    +          x =>
    --- End diff --
    
    move this to above line like properties.foreach { x =>


---

Reply via email to