You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by ravipesala <gi...@git.apache.org> on 2017/11/09 11:37:52 UTC

[GitHub] carbondata pull request #1446: [CARBONDATA-1520] [PreAgg] Support pre-aggreg...

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

    https://github.com/apache/carbondata/pull/1446#discussion_r149938131
  
    --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/preaaggregate/LoadPostAggregateListener.scala ---
    @@ -0,0 +1,50 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.execution.command.preaaggregate
    +
    +import scala.collection.JavaConverters._
    +
    +import org.apache.carbondata.core.constants.CarbonLoadOptionConstants
    +import org.apache.carbondata.core.metadata.schema.table.DataMapSchema
    +import org.apache.carbondata.core.util.ThreadLocalSessionInfo
    +import org.apache.carbondata.events.{Event, LoadTablePostExecutionEvent, OperationContext, OperationEventListener}
    +
    +class LoadPostAggregateListener extends OperationEventListener {
    +  /**
    +   * Called on a specified event occurrence
    +   *
    +   * @param event
    +   */
    +  override def onEvent(event: Event, operationContext: OperationContext): Unit = {
    +    val loadEvent = event.asInstanceOf[LoadTablePostExecutionEvent]
    +    val sparkSession = loadEvent.sparkSession
    +    val carbonLoadModel = loadEvent.carbonLoadModel
    +    val table = carbonLoadModel.getCarbonDataLoadSchema.getCarbonTable
    +    if (!table.getTableInfo.getDataMapSchemaList.isEmpty) {
    +      for (dataMapSchema: DataMapSchema <- table.getTableInfo.getDataMapSchemaList.asScala) {
    +        ThreadLocalSessionInfo.getCarbonSessionInfo.getSessionParams
    +          .addProperty(CarbonLoadOptionConstants.CARBON_AGGREGATE_SEGMENTS,
    +            carbonLoadModel.getSegmentId)
    +        val childTableName = dataMapSchema.getRelationIdentifier.getTableName
    +        val childDatabaseName = dataMapSchema.getRelationIdentifier.getDatabaseName
    +        val selectQuery = dataMapSchema.getProperties.get("CHILD_SELECT QUERY")
    +        sparkSession.sql(s"insert into $childDatabaseName.$childTableName $selectQuery")
    --- End diff --
    
    Use LoadTableCommand directly and pass the segment information to it.


---