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

    https://github.com/apache/carbondata/pull/1476#discussion_r150493685
  
    --- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/preaaggregate/PreAggregateListeners.scala
 ---
    @@ -79,3 +79,190 @@ object LoadPostAggregateListener extends 
OperationEventListener {
         }
       }
     }
    +
    +object PreAggregateDataTypeChangePreListener extends 
OperationEventListener {
    +  /**
    +   * Called on a specified event occurrence
    +   *
    +   * @param event
    +   * @param operationContext
    +   */
    +  override def onEvent(event: Event, operationContext: OperationContext): 
Unit = {
    +    val dataTypeChangePreListener = 
event.asInstanceOf[AlterTableDataTypeChangePreEvent]
    +    val carbonTable = dataTypeChangePreListener.carbonTable
    +    val alterTableDataTypeChangeModel = 
dataTypeChangePreListener.alterTableDataTypeChangeModel
    +    val columnToBeAltered: String = 
alterTableDataTypeChangeModel.columnName
    +    val dataMapSchemas = carbonTable.getTableInfo.getDataMapSchemaList
    +    if (dataMapSchemas != null && !dataMapSchemas.isEmpty) {
    +      dataMapSchemas.asScala.foreach {
    +        dataMapSchema =>
    +          val childColumns = dataMapSchema.getChildSchema.getListOfColumns
    +          if (childColumns.asScala.exists(_.getColumnName == 
columnToBeAltered)) {
    +            throw new UnsupportedOperationException(s"Column 
$columnToBeAltered exists in a " +
    +                                                    s"pre-aggregate table 
${
    +                                                      
dataMapSchema.toString}. Cannot change datatype")
    +          }
    +      }
    +
    +      if (carbonTable.isPreAggregateTable) {
    +        throw new UnsupportedOperationException(s"Cannot change data type 
for columns in " +
    +                                                s"pre-aggreagate table ${
    +                                                  
carbonTable.getDatabaseName}.${ carbonTable.getFactTableName }")
    +      }
    +    }
    +  }
    +}
    +
    +object PreAggregateDeleteSegmentByDatePreListener extends 
OperationEventListener {
    +  /**
    +   * Called on a specified event occurrence
    +   *
    +   * @param event
    +   * @param operationContext
    +   */
    +  override def onEvent(event: Event, operationContext: OperationContext): 
Unit = {
    +    val deleteSegmentByDatePreEvent = 
event.asInstanceOf[DeleteSegmentByDatePreEvent]
    +    val carbonTable = deleteSegmentByDatePreEvent.carbonTable
    +    if (carbonTable != null) {
    +      if (carbonTable.hasPreAggregateTables) {
    +        throw new UnsupportedOperationException(
    +          "Delete segment operation is not supported on tables which have 
a pre-aggregate table. " +
    +          "Drop pre-aggregation table to continue")
    +      }
    +      if (carbonTable.isPreAggregateTable) {
    +        throw new UnsupportedOperationException(
    +          "Delete segment operation is not supported on pre-aggregate 
table")
    +      }
    +    }
    +  }
    +}
    +
    +object PreAggregateDeleteSegmentByIdPreListener extends 
OperationEventListener {
    +  /**
    +   * Called on a specified event occurrence
    +   *
    +   * @param event
    +   * @param operationContext
    +   */
    +  override def onEvent(event: Event, operationContext: OperationContext): 
Unit = {
    +    val tableEvent = event.asInstanceOf[DeleteSegmentByIdPreEvent]
    +    val carbonTable = tableEvent.carbonTable
    +    if (carbonTable != null) {
    +      if (carbonTable.hasPreAggregateTables) {
    +        throw new UnsupportedOperationException(
    +          "Delete segment operation is not supported on tables which have 
a pre-aggregate table")
    +      }
    +      if (carbonTable.isPreAggregateTable) {
    +        throw new UnsupportedOperationException(
    +          "Delete segment operation is not supported on pre-aggregate 
table")
    +      }
    +    }
    +  }
    +
    +}
    +
    +object PreAggregateDropColumnPreListener extends OperationEventListener {
    +  /**
    +   * Called on a specified event occurrence
    +   *
    +   * @param event
    +   * @param operationContext
    +   */
    +  override def onEvent(event: Event, operationContext: OperationContext): 
Unit = {
    +    val dataTypeChangePreListener = 
event.asInstanceOf[AlterTableDropColumnPreEvent]
    +    val carbonTable = dataTypeChangePreListener.carbonTable
    +    val alterTableDropColumnModel = 
dataTypeChangePreListener.alterTableDropColumnModel
    +    val columnsToBeDropped = alterTableDropColumnModel.columns
    +    val dataMapSchemas = carbonTable.getTableInfo.getDataMapSchemaList
    +    if (dataMapSchemas != null && !dataMapSchemas.isEmpty) {
    +      dataMapSchemas.asScala.foreach {
    +        dataMapSchema =>
    --- End diff --
    
    move to above line


---

Reply via email to