carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sounakr <...@git.apache.org>
Subject [GitHub] carbondata pull request #1595: [CARBONDATA-1868][Spark-2.2]Carbon-Spark2.2 I...
Date Thu, 07 Dec 2017 04:13:04 GMT
Github user sounakr commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1595#discussion_r155427034
  
    --- Diff: integration/spark2/src/main/spark2.2/CarbonSessionState.scala ---
    @@ -256,6 +292,57 @@ class CarbonSqlAstBuilder(conf: SQLConf, parser: CarbonSpark2SqlParser)
extends
         }
       }
     
    +  override def visitChangeColumn(ctx: ChangeColumnContext): LogicalPlan = {
    +
    +    val newColumn = visitColType(ctx.colType)
    +    if (!ctx.identifier.getText.equalsIgnoreCase(newColumn.name)) {
    +      throw new MalformedCarbonCommandException(
    +        "Column names provided are different. Both the column names should be same")
    +    }
    +
    +    val (typeString, values) : (String, Option[List[(Int, Int)]]) = newColumn.dataType
match {
    +      case d:DecimalType => ("decimal", Some(List((d.precision, d.scale))))
    +      case _ => (newColumn.dataType.typeName.toLowerCase, None)
    +    }
    +
    +    val alterTableChangeDataTypeModel =
    +      AlterTableDataTypeChangeModel(new CarbonSpark2SqlParser().parseDataType(typeString,
values),
    +        new CarbonSpark2SqlParser()
    +          .convertDbNameToLowerCase(Option(ctx.tableIdentifier().db).map(_.getText)),
    +        ctx.tableIdentifier().table.getText.toLowerCase,
    +        ctx.identifier.getText.toLowerCase,
    +        newColumn.name.toLowerCase)
    +
    +    CarbonAlterTableDataTypeChangeCommand(alterTableChangeDataTypeModel)
    +  }
    +
    +
    +  override def visitAddTableColumns(ctx: AddTableColumnsContext): LogicalPlan = {
    --- End diff --
    
    We can catch the command in strategy. But as AlterTableChangeColumnCommand is only added
in Spark 2.2. As our strategy is common for spark2.2. and spark2.1 it will be difficult to
match the case of AlterTableAddColumnsCommand. Currently the SparkSqlAstBuilder is separated
in 2.1 and 2.2 in CarbonSessionState.scala so it was easier to place it over there. 


---

Mime
View raw message