carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anubhav100 <...@git.apache.org>
Subject [GitHub] carbondata pull request #984: [CARBONDATA-1008] Make Caron table schema comp...
Date Mon, 10 Jul 2017 12:46:12 GMT
Github user anubhav100 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/984#discussion_r126410819
  
    --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchema.scala
---
    @@ -195,11 +195,43 @@ case class CreateTable(cm: TableModel, createDSTable: Boolean =
true) extends Ru
               val fields = new Array[Field](cm.dimCols.size + cm.msrCols.size)
               cm.dimCols.foreach(f => fields(f.schemaOrdinal) = f)
               cm.msrCols.foreach(f => fields(f.schemaOrdinal) = f)
    -          sparkSession.sql(
    -            s"""CREATE TABLE $dbName.$tbName
    -                |(${ fields.map(f => f.rawSchema).mkString(",") })
    -                |USING org.apache.spark.sql.CarbonSource""".stripMargin +
    -            s""" OPTIONS (tableName "$tbName", dbName "$dbName", tablePath "$tablePath")
""")
    +          val useCompatibleSchema = sparkSession.sparkContext.conf
    +            .getBoolean(CarbonCommonConstants.SPARK_SCHEMA_HIVE_COMPATIBILITY_ENABLE,
false)
    +          if (useCompatibleSchema) {
    +            val tableIdentifier = TableIdentifier(tbName, Some(dbName))
    +            val tableSchema = CarbonEnv.getInstance(sparkSession).carbonMetastore
    +              .lookupRelation(tableIdentifier)(sparkSession).schema.json
    +            val schemaParts = AlterTableUtil.prepareSchemaJsonForAlterTable(
    +              sparkSession.sparkContext.conf, tableSchema)
    +            sparkSession.sharedState.externalCatalog.asInstanceOf[HiveExternalCatalog].client
    --- End diff --
    
    @cenyuhai change this code to  sparkSession.sessionState.asInstanceOf[CarbonSessionState].metadataHive
beause you can not alter a hive table this table does not exists in carbon metastore 
    look below,i tried it and get a exception
    
    cala> carbon.sql("alter table idsr226617624713 add columns(name string) ")
    org.apache.carbondata.spark.exception.MalformedCarbonCommandException: Unsupported alter
operation on hive table
    after changing the code it works fine
    



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message