carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jackylk <...@git.apache.org>
Subject [GitHub] carbondata pull request #1489: [CARBONDATA-1576][PREAGG][DATAMAP] Support Da...
Date Mon, 13 Nov 2017 11:00:55 GMT
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1489#discussion_r150506019
  
    --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/preaaggregate/CreatePreAggregateTableCommand.scala
---
    @@ -79,24 +79,26 @@ case class CreatePreAggregateTableCommand(
         tableModel.parentTable = Some(parentTable)
         tableModel.dataMapRelation = Some(fieldRelationMap)
         CarbonCreateTableCommand(tableModel, createDSTable = true).run (sparkSession)
    -      try {
    +    try {
           val relation = CarbonEnv.getInstance(sparkSession).carbonMetastore.
    -      lookupRelation( tableIdentifier)(sparkSession).asInstanceOf[CarbonRelation]
    -      val tableInfo= relation.tableMeta.carbonTable.getTableInfo
    -          // child schema object which will be updated on parent table about the
    -          val childSchema = tableInfo.getFactTable
    -            .buildChildSchema(dataMapName,"", tableInfo.getDatabaseName, queryString,
"AGGREGATION")
    -      childSchema.setProperties(dmproperties.asJava)    // upadting the parent table
about child table
    -          PreAggregateUtil.updateMainTable(parentDbName, parentTableName, childSchema,
sparkSession)
    -        val loadAvailable = PreAggregateUtil
    -            .checkMainTableLoad(parentTable)
    -          if (loadAvailable) {
    -            sparkSession.sql(s"insert into ${ cm.databaseName }.${ cm.tableName } $queryString")
    -          }} catch {
    -          case e: Exception =>
    -            sparkSession.
    -              sql(s"""DROP TABLE IF EXISTS ${tableModel.databaseName}.${tableModel.tableName}""")
    -            throw e
    +        lookupRelation(tableIdentifier)(sparkSession).asInstanceOf[CarbonRelation]
    +      val tableInfo = relation.tableMeta.carbonTable.getTableInfo
    +      // child schema object which will be updated on parent table about the
    +      val childSchema = tableInfo.getFactTable
    +        .buildChildSchema(dataMapName, "", tableInfo.getDatabaseName, queryString, "AGGREGATION")
    +      dmproperties.foreach(f => childSchema.getProperties.put(f._1, f._2))
    +      // updating the parent table about child table
    +      PreAggregateUtil.updateMainTable(parentDbName, parentTableName, childSchema, sparkSession)
    +      val loadAvailable = PreAggregateUtil.checkMainTableLoad(parentTable)
    +      if (loadAvailable) {
    +        sparkSession
    +          .sql(s"insert into ${ tableModel.databaseName }.${ tableModel.tableName } $queryString")
    +      }
    +    } catch {
    +      case e: Exception =>
    +        sparkSession.
    +          sql(s"""DROP TABLE IF EXISTS ${ tableModel.databaseName }.${ tableModel.tableName
}""")
    --- End diff --
    
    Can we use programmical way instead of issuing another SQL?


---

Mime
View raw message