Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8C8C5200D46 for ; Sun, 26 Nov 2017 13:13:40 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 81A43160BFF; Sun, 26 Nov 2017 12:13:40 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C7E44160BFA for ; Sun, 26 Nov 2017 13:13:39 +0100 (CET) Received: (qmail 25778 invoked by uid 500); 26 Nov 2017 12:13:39 -0000 Mailing-List: contact issues-help@carbondata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@carbondata.apache.org Delivered-To: mailing list issues@carbondata.apache.org Received: (qmail 25769 invoked by uid 99); 26 Nov 2017 12:13:39 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Nov 2017 12:13:39 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2F6A0E02F6; Sun, 26 Nov 2017 12:13:37 +0000 (UTC) From: ravipesala To: issues@carbondata.apache.org Reply-To: issues@carbondata.apache.org References: In-Reply-To: Subject: [GitHub] carbondata pull request #1508: [CARBONDATA-1738] [PreAgg] Block direct inser... Content-Type: text/plain Message-Id: <20171126121338.2F6A0E02F6@git1-us-west.apache.org> Date: Sun, 26 Nov 2017 12:13:37 +0000 (UTC) archived-at: Sun, 26 Nov 2017 12:13:40 -0000 Github user ravipesala commented on a diff in the pull request: https://github.com/apache/carbondata/pull/1508#discussion_r153068092 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/preaaggregate/PreAggregateListeners.scala --- @@ -49,13 +50,52 @@ object LoadPostAggregateListener extends OperationEventListener { carbonLoadModel.getTableName, "false") 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") + val childDataFrame = sparkSession.sql(new CarbonSpark2SqlParser() + .addPreAggLoadFunction(s"${dataMapSchema.getProperties.get("CHILD_SELECT QUERY")} ")).drop("preAggLoad") + val headers = dataMapSchema.getChildSchema.getListOfColumns.asScala.map(_.getColumnName) + .mkString(",") + try { + LoadTableCommand(Some(childDatabaseName), + childTableName, + null, + Nil, + Map("fileheader" -> headers), + isOverwriteTable = false, + dataFrame = Some(childDataFrame), + internalOptions = Map(CarbonCommonConstants.IS_INTERNAL_LOAD_CALL -> "true")).run(sparkSession) + } finally { + CarbonSession.threadUnset(CarbonCommonConstants.CARBON_INPUT_SEGMENTS + + carbonLoadModel.getDatabaseName + "." + + carbonLoadModel.getTableName) + CarbonSession.threadUnset(CarbonCommonConstants.VALIDATE_CARBON_INPUT_SEGMENTS + + carbonLoadModel.getDatabaseName + "." + + carbonLoadModel.getTableName) --- End diff -- Indentation is wrong, format properly ---