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

    
https://github.com/apache/incubator-carbondata/pull/641#discussion_r106092997
  
    --- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSpark2SqlParser.scala
 ---
    @@ -129,4 +134,80 @@ class CarbonSpark2SqlParser extends CarbonDDLSqlParser 
{
           case databaseName ~ tableName ~ limit =>
             ShowLoadsCommand(convertDbNameToLowerCase(databaseName), 
tableName.toLowerCase(), limit)
         }
    +
    +  protected lazy val alterTableModifyDataType: Parser[LogicalPlan] =
    +    ALTER ~> TABLE ~> (ident <~ ".").? ~ ident ~ CHANGE ~ ident ~ ident ~
    +    ident ~ opt("(" ~> rep1sep(valueOptions, ",") <~ ")") <~ opt(";") ^^ {
    +      case dbName ~ table ~ change ~ columnName ~ columnNameCopy ~ 
dataType ~ values =>
    +        // both the column names should be same
    +        CommonUtil.validateColumnNames(columnName, columnNameCopy)
    +        val alterTableChangeDataTypeModel =
    +          
AlterTableDataTypeChangeModel(parseDataType(dataType.toLowerCase, values),
    +            convertDbNameToLowerCase(dbName),
    +            table.toLowerCase,
    +            columnName.toLowerCase,
    +            columnNameCopy.toLowerCase)
    +        AlterTableDataTypeChange(alterTableChangeDataTypeModel)
    +    }
    +
    +  protected lazy val alterTableAddColumns: Parser[LogicalPlan] =
    +    ALTER ~> TABLE ~> (ident <~ ".").? ~ ident ~
    +    (ADD ~> COLUMNS ~> "(" ~> repsep(anyFieldDef, ",") <~ ")") ~
    +    (TBLPROPERTIES ~> "(" ~> repsep(loadOptions, ",") <~ ")").? <~ 
opt(";") ^^ {
    +      case dbName ~ table ~ fields ~ tblProp =>
    +        fields.foreach{ f =>
    +          if (isComplexDimDictionaryExclude(f.dataType.get)) {
    +            throw new MalformedCarbonCommandException(
    +              s"Add column is unsupported for complex datatype column: 
${f.column}")
    +          }
    +        }
    +        val tableProps = if (tblProp.isDefined) {
    +          // default value should not be converted to lower case
    +          val tblProps = tblProp.get.map(f => if 
(f._1.toLowerCase.startsWith("default.value.")) {
    +            f._1 -> f._2
    +          } else {
    +            f._1 -> f._2.toLowerCase
    +          })
    +          scala.collection.mutable.Map(tblProps: _*)
    +        } else {
    +          scala.collection.mutable.Map.empty[String, String]
    +        }
    +
    +        val tableModel = prepareTableModel (false,
    +          convertDbNameToLowerCase(dbName),
    +          table.toLowerCase,
    +          fields.map(convertFieldNamesToLowercase),
    +          Seq.empty,
    +          tableProps,
    +          None,
    +          true)
    +
    +        val alterTableAddColumnsModel = 
AlterTableAddColumnsModel(convertDbNameToLowerCase(dbName),
    +          table,
    +          tableProps,
    +          tableModel.dimCols,
    +          tableModel.msrCols,
    +          tableModel.highcardinalitydims.getOrElse(Seq.empty))
    +        AlterTableAddColumns(alterTableAddColumnsModel)
    +    }
    +
    +  private def convertFieldNamesToLowercase(field: Field): Field = {
    +    val name = field.column.toLowerCase
    +    field.copy(column = name, name = Some(name))
    +  }
    +  protected lazy val alterTableDropColumn: Parser[LogicalPlan] =
    --- End diff --
    
    Add rule name columnlist, which can check duplicates and related validation


---
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