Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150503957 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateDrop.scala --- @@ -42,14 +42,14 @@ class TestPreAggregateDrop extends QueryTest with BeforeAndAfterAll { "create datamap preagg1 on table maintable using 'preaggregate' as select" + " a,sum(b) from maintable group by a") sql( - "create datamap preagg2 on table maintable using 'preaggregate' as select" + + "create datamap preagg2 on table maintable using 'preaggregate' as select" + " a,sum(c) from maintable group by a") - sql("drop table if exists preagg2") + sql("drop datamap if exists preagg2 on table maintable") val showTables = sql("show tables") checkExistence(showTables, false, "preagg2") checkExistence(showTables, true, "preagg1") } - + test("drop main table and check if preaggreagte is deleted") { sql( --- End diff -- please add a testcase to drop two same name datamap in different table --- |
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150504150 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateDrop.scala --- @@ -42,14 +42,14 @@ class TestPreAggregateDrop extends QueryTest with BeforeAndAfterAll { "create datamap preagg1 on table maintable using 'preaggregate' as select" + " a,sum(b) from maintable group by a") sql( - "create datamap preagg2 on table maintable using 'preaggregate' as select" + + "create datamap preagg2 on table maintable using 'preaggregate' as select" + " a,sum(c) from maintable group by a") - sql("drop table if exists preagg2") + sql("drop datamap if exists preagg2 on table maintable") val showTables = sql("show tables") checkExistence(showTables, false, "preagg2") checkExistence(showTables, true, "preagg1") } - + test("drop main table and check if preaggreagte is deleted") { sql( "create datamap preagg2 on table maintable using 'preaggregate' as select" + --- End diff -- please add a testcase to drop datamap and create same name datamap again on same table --- |
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150504312 --- Diff: integration/spark-common/src/main/scala/org/apache/carbondata/events/DropDataMapEvents.scala --- @@ -0,0 +1,54 @@ +/* + * 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.carbondata.events + +import org.apache.spark.sql.SparkSession + +import org.apache.carbondata.core.metadata.schema.table.{CarbonTable, DataMapSchema} + + +/** + * + * @param ifExistsSet + * @param sparkSession + */ +case class DropDataMapPreEvent( --- End diff -- describe in comment when this event will be triggered --- |
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150504460 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/CarbonDropDataMapCommand.scala --- @@ -0,0 +1,141 @@ +/* + * 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.datamap + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql.{CarbonEnv, GetDB, Row, SparkSession} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.catalyst.analysis.NoSuchTableException +import org.apache.spark.sql.execution.command.{DataProcessCommand, RunnableCommand, SchemaProcessCommand} +import org.apache.spark.sql.execution.command.preaaggregate.PreAggregateUtil +import org.apache.spark.sql.hive.CarbonRelation + +import org.apache.carbondata.common.logging.{LogService, LogServiceFactory} +import org.apache.carbondata.core.datamap.DataMapStoreManager +import org.apache.carbondata.core.locks.{CarbonLockUtil, ICarbonLock, LockUsage} +import org.apache.carbondata.core.metadata.{AbsoluteTableIdentifier, CarbonTableIdentifier} +import org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl +import org.apache.carbondata.core.metadata.schema.table.CarbonTable +import org.apache.carbondata.events._ + + +case class CarbonDropDataMapCommand( + dataMapName: String, + ifExistsSet: Boolean, + databaseNameOp: Option[String], + tableName: String) + extends RunnableCommand with SchemaProcessCommand with DataProcessCommand { + + override def run(sparkSession: SparkSession): Seq[Row] = { + processSchema(sparkSession) + processData(sparkSession) + } + + override def processSchema(sparkSession: SparkSession): Seq[Row] = { + val LOGGER: LogService = LogServiceFactory.getLogService(this.getClass.getCanonicalName) + val dbName = GetDB.getDatabaseName(databaseNameOp, sparkSession) + val identifier = TableIdentifier(tableName, Option(dbName)) + val carbonTableIdentifier = new CarbonTableIdentifier(dbName, tableName, "") + val locksToBeAcquired = List(LockUsage.METADATA_LOCK) + val carbonEnv = CarbonEnv.getInstance(sparkSession) + val catalog = carbonEnv.carbonMetastore + val tableIdentifier = + AbsoluteTableIdentifier.from(CarbonEnv.getInstance(sparkSession).storePath, + dbName.toLowerCase, tableName.toLowerCase) + catalog.checkSchemasModifiedTimeAndReloadTables(tableIdentifier.getStorePath) + val carbonLocks: scala.collection.mutable.ListBuffer[ICarbonLock] = ListBuffer() + try { + locksToBeAcquired foreach { + lock => carbonLocks += CarbonLockUtil.getLockObject(carbonTableIdentifier, lock) + } + LOGGER.audit(s"Deleting datamap [$dataMapName] under table [$tableName]") + val carbonTable: Option[CarbonTable] = + catalog.getTableFromMetadataCache(dbName, tableName) match { + case Some(tableMeta) => Some(tableMeta.carbonTable) + case None => try { + Some(catalog.lookupRelation(identifier)(sparkSession) + .asInstanceOf[CarbonRelation].metaData.carbonTable) + } catch { + case ex: NoSuchTableException => + if (!ifExistsSet) { + throw ex + } + None + } + } + if (carbonTable.isDefined && carbonTable.get.getTableInfo.getDataMapSchemaList.size() > 0) { + val dataMapSchema = carbonTable.get.getTableInfo.getDataMapSchemaList.asScala.zipWithIndex. + find(_._1.getDataMapName.equalsIgnoreCase(dataMapName)) + if (dataMapSchema.isDefined) { + + val operationContext = new OperationContext + val dropDataMapPreEvent = + DropDataMapPreEvent( + Some(dataMapSchema.get._1), + ifExistsSet, + sparkSession) + OperationListenerBus.getInstance.fireEvent(dropDataMapPreEvent, operationContext) + + carbonTable.get.getTableInfo.getDataMapSchemaList.remove(dataMapSchema.get._2) + val schemaConverter = new ThriftWrapperSchemaConverterImpl + PreAggregateUtil + .updateSchemaInfo(carbonTable.get, --- End diff -- move to previous line, move parameter to next line --- |
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150504821 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/CarbonDropDataMapCommand.scala --- @@ -0,0 +1,141 @@ +/* + * 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.datamap + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql.{CarbonEnv, GetDB, Row, SparkSession} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.catalyst.analysis.NoSuchTableException +import org.apache.spark.sql.execution.command.{DataProcessCommand, RunnableCommand, SchemaProcessCommand} +import org.apache.spark.sql.execution.command.preaaggregate.PreAggregateUtil +import org.apache.spark.sql.hive.CarbonRelation + +import org.apache.carbondata.common.logging.{LogService, LogServiceFactory} +import org.apache.carbondata.core.datamap.DataMapStoreManager +import org.apache.carbondata.core.locks.{CarbonLockUtil, ICarbonLock, LockUsage} +import org.apache.carbondata.core.metadata.{AbsoluteTableIdentifier, CarbonTableIdentifier} +import org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl +import org.apache.carbondata.core.metadata.schema.table.CarbonTable +import org.apache.carbondata.events._ + + +case class CarbonDropDataMapCommand( + dataMapName: String, + ifExistsSet: Boolean, + databaseNameOp: Option[String], + tableName: String) + extends RunnableCommand with SchemaProcessCommand with DataProcessCommand { + + override def run(sparkSession: SparkSession): Seq[Row] = { + processSchema(sparkSession) + processData(sparkSession) + } + + override def processSchema(sparkSession: SparkSession): Seq[Row] = { + val LOGGER: LogService = LogServiceFactory.getLogService(this.getClass.getCanonicalName) + val dbName = GetDB.getDatabaseName(databaseNameOp, sparkSession) + val identifier = TableIdentifier(tableName, Option(dbName)) + val carbonTableIdentifier = new CarbonTableIdentifier(dbName, tableName, "") + val locksToBeAcquired = List(LockUsage.METADATA_LOCK) + val carbonEnv = CarbonEnv.getInstance(sparkSession) + val catalog = carbonEnv.carbonMetastore + val tableIdentifier = + AbsoluteTableIdentifier.from(CarbonEnv.getInstance(sparkSession).storePath, + dbName.toLowerCase, tableName.toLowerCase) + catalog.checkSchemasModifiedTimeAndReloadTables(tableIdentifier.getStorePath) + val carbonLocks: scala.collection.mutable.ListBuffer[ICarbonLock] = ListBuffer() + try { + locksToBeAcquired foreach { + lock => carbonLocks += CarbonLockUtil.getLockObject(carbonTableIdentifier, lock) + } + LOGGER.audit(s"Deleting datamap [$dataMapName] under table [$tableName]") + val carbonTable: Option[CarbonTable] = + catalog.getTableFromMetadataCache(dbName, tableName) match { + case Some(tableMeta) => Some(tableMeta.carbonTable) + case None => try { + Some(catalog.lookupRelation(identifier)(sparkSession) + .asInstanceOf[CarbonRelation].metaData.carbonTable) + } catch { + case ex: NoSuchTableException => + if (!ifExistsSet) { + throw ex + } + None + } + } + if (carbonTable.isDefined && carbonTable.get.getTableInfo.getDataMapSchemaList.size() > 0) { + val dataMapSchema = carbonTable.get.getTableInfo.getDataMapSchemaList.asScala.zipWithIndex. + find(_._1.getDataMapName.equalsIgnoreCase(dataMapName)) + if (dataMapSchema.isDefined) { + + val operationContext = new OperationContext + val dropDataMapPreEvent = + DropDataMapPreEvent( + Some(dataMapSchema.get._1), + ifExistsSet, + sparkSession) + OperationListenerBus.getInstance.fireEvent(dropDataMapPreEvent, operationContext) + + carbonTable.get.getTableInfo.getDataMapSchemaList.remove(dataMapSchema.get._2) + val schemaConverter = new ThriftWrapperSchemaConverterImpl + PreAggregateUtil + .updateSchemaInfo(carbonTable.get, + schemaConverter + .fromWrapperToExternalTableInfo(carbonTable.get.getTableInfo, + dbName, + tableName))(sparkSession) + // fires the event after dropping datamap from main table schema + val dropDataMapPostEvent = + DropDataMapPostEvent( + Some(dataMapSchema.get._1), + ifExistsSet, + sparkSession) + OperationListenerBus.getInstance.fireEvent(dropDataMapPostEvent, operationContext) + } else if (!ifExistsSet) { + throw new Exception( --- End diff -- throw IllegalArgumentException --- |
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150505002 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/CarbonDropDataMapCommand.scala --- @@ -0,0 +1,141 @@ +/* + * 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.datamap + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql.{CarbonEnv, GetDB, Row, SparkSession} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.catalyst.analysis.NoSuchTableException +import org.apache.spark.sql.execution.command.{DataProcessCommand, RunnableCommand, SchemaProcessCommand} +import org.apache.spark.sql.execution.command.preaaggregate.PreAggregateUtil +import org.apache.spark.sql.hive.CarbonRelation + +import org.apache.carbondata.common.logging.{LogService, LogServiceFactory} +import org.apache.carbondata.core.datamap.DataMapStoreManager +import org.apache.carbondata.core.locks.{CarbonLockUtil, ICarbonLock, LockUsage} +import org.apache.carbondata.core.metadata.{AbsoluteTableIdentifier, CarbonTableIdentifier} +import org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl +import org.apache.carbondata.core.metadata.schema.table.CarbonTable +import org.apache.carbondata.events._ + + +case class CarbonDropDataMapCommand( + dataMapName: String, + ifExistsSet: Boolean, + databaseNameOp: Option[String], + tableName: String) + extends RunnableCommand with SchemaProcessCommand with DataProcessCommand { + + override def run(sparkSession: SparkSession): Seq[Row] = { + processSchema(sparkSession) + processData(sparkSession) + } + + override def processSchema(sparkSession: SparkSession): Seq[Row] = { + val LOGGER: LogService = LogServiceFactory.getLogService(this.getClass.getCanonicalName) --- End diff -- add some comment to describe what it does in this command --- |
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150505587 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/DataMapListeners.scala --- @@ -0,0 +1,71 @@ +/* + * 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.datamap + +import scala.collection.JavaConverters._ + +import org.apache.spark.sql.execution.command.CarbonDropTableCommand + +import org.apache.carbondata.core.metadata.schema.table.DataMapSchema +import org.apache.carbondata.events.{DropDataMapPostEvent, DropTablePostEvent, Event, OperationContext, OperationEventListener} + +object DataMapDropTablePostListener extends OperationEventListener { + + /** + * Called on a specified event occurrence + * + * @param event + */ + override def onEvent(event: Event, operationContext: OperationContext): Unit = { + val dropPostEvent = event.asInstanceOf[DropTablePostEvent] + val carbonTable = dropPostEvent.carbonTable + val sparkSession = dropPostEvent.sparkSession + if (carbonTable.isDefined && carbonTable.get.getTableInfo.getDataMapSchemaList != null && + !carbonTable.get.getTableInfo.getDataMapSchemaList.isEmpty) { + val childSchemas = carbonTable.get.getTableInfo.getDataMapSchemaList + for (childSchema: DataMapSchema <- childSchemas.asScala) { + if (childSchema.getRelationIdentifier != null) { + CarbonDropTableCommand(ifExistsSet = true, --- End diff -- change like: ``` CarbonDropTableCommand( ifExistsSet = true, Some(childSchema.getRelationIdentifier.getDatabaseName), childSchema.getRelationIdentifier.getTableName, true ).run(sparkSession) ``` --- |
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150505980 --- 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") --- End diff -- Can we use programmical way instead of issuing another SQL? --- |
In reply to this post by qiuchenjian-2
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? --- |
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150506244 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSpark2SqlParser.scala --- @@ -135,6 +135,13 @@ class CarbonSpark2SqlParser extends CarbonDDLSqlParser { CreateDataMapCommand(dmname, TableIdentifier(tableName, dbName), className, map, query) } + protected lazy val dropDataMap: Parser[LogicalPlan] = --- End diff -- please add syntax description --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150510275 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateDrop.scala --- @@ -42,14 +42,14 @@ class TestPreAggregateDrop extends QueryTest with BeforeAndAfterAll { "create datamap preagg1 on table maintable using 'preaggregate' as select" + " a,sum(b) from maintable group by a") sql( - "create datamap preagg2 on table maintable using 'preaggregate' as select" + + "create datamap preagg2 on table maintable using 'preaggregate' as select" + " a,sum(c) from maintable group by a") - sql("drop table if exists preagg2") + sql("drop datamap if exists preagg2 on table maintable") val showTables = sql("show tables") checkExistence(showTables, false, "preagg2") checkExistence(showTables, true, "preagg1") } - + test("drop main table and check if preaggreagte is deleted") { --- End diff -- ok --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150511779 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateDrop.scala --- @@ -42,14 +42,14 @@ class TestPreAggregateDrop extends QueryTest with BeforeAndAfterAll { "create datamap preagg1 on table maintable using 'preaggregate' as select" + " a,sum(b) from maintable group by a") sql( - "create datamap preagg2 on table maintable using 'preaggregate' as select" + + "create datamap preagg2 on table maintable using 'preaggregate' as select" + " a,sum(c) from maintable group by a") - sql("drop table if exists preagg2") + sql("drop datamap if exists preagg2 on table maintable") val showTables = sql("show tables") checkExistence(showTables, false, "preagg2") checkExistence(showTables, true, "preagg1") } - + test("drop main table and check if preaggreagte is deleted") { sql( --- End diff -- ok --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150512789 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateDrop.scala --- @@ -42,14 +42,14 @@ class TestPreAggregateDrop extends QueryTest with BeforeAndAfterAll { "create datamap preagg1 on table maintable using 'preaggregate' as select" + " a,sum(b) from maintable group by a") sql( - "create datamap preagg2 on table maintable using 'preaggregate' as select" + + "create datamap preagg2 on table maintable using 'preaggregate' as select" + " a,sum(c) from maintable group by a") - sql("drop table if exists preagg2") + sql("drop datamap if exists preagg2 on table maintable") val showTables = sql("show tables") checkExistence(showTables, false, "preagg2") checkExistence(showTables, true, "preagg1") } - + test("drop main table and check if preaggreagte is deleted") { sql( "create datamap preagg2 on table maintable using 'preaggregate' as select" + --- End diff -- ok --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150512810 --- Diff: integration/spark-common/src/main/scala/org/apache/carbondata/events/DropDataMapEvents.scala --- @@ -0,0 +1,54 @@ +/* + * 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.carbondata.events + +import org.apache.spark.sql.SparkSession + +import org.apache.carbondata.core.metadata.schema.table.{CarbonTable, DataMapSchema} + + +/** + * + * @param ifExistsSet + * @param sparkSession + */ +case class DropDataMapPreEvent( --- End diff -- ok --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150513015 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/CarbonDropDataMapCommand.scala --- @@ -0,0 +1,141 @@ +/* + * 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.datamap + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql.{CarbonEnv, GetDB, Row, SparkSession} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.catalyst.analysis.NoSuchTableException +import org.apache.spark.sql.execution.command.{DataProcessCommand, RunnableCommand, SchemaProcessCommand} +import org.apache.spark.sql.execution.command.preaaggregate.PreAggregateUtil +import org.apache.spark.sql.hive.CarbonRelation + +import org.apache.carbondata.common.logging.{LogService, LogServiceFactory} +import org.apache.carbondata.core.datamap.DataMapStoreManager +import org.apache.carbondata.core.locks.{CarbonLockUtil, ICarbonLock, LockUsage} +import org.apache.carbondata.core.metadata.{AbsoluteTableIdentifier, CarbonTableIdentifier} +import org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl +import org.apache.carbondata.core.metadata.schema.table.CarbonTable +import org.apache.carbondata.events._ + + +case class CarbonDropDataMapCommand( + dataMapName: String, + ifExistsSet: Boolean, + databaseNameOp: Option[String], + tableName: String) + extends RunnableCommand with SchemaProcessCommand with DataProcessCommand { + + override def run(sparkSession: SparkSession): Seq[Row] = { + processSchema(sparkSession) + processData(sparkSession) + } + + override def processSchema(sparkSession: SparkSession): Seq[Row] = { + val LOGGER: LogService = LogServiceFactory.getLogService(this.getClass.getCanonicalName) + val dbName = GetDB.getDatabaseName(databaseNameOp, sparkSession) + val identifier = TableIdentifier(tableName, Option(dbName)) + val carbonTableIdentifier = new CarbonTableIdentifier(dbName, tableName, "") + val locksToBeAcquired = List(LockUsage.METADATA_LOCK) + val carbonEnv = CarbonEnv.getInstance(sparkSession) + val catalog = carbonEnv.carbonMetastore + val tableIdentifier = + AbsoluteTableIdentifier.from(CarbonEnv.getInstance(sparkSession).storePath, + dbName.toLowerCase, tableName.toLowerCase) + catalog.checkSchemasModifiedTimeAndReloadTables(tableIdentifier.getStorePath) + val carbonLocks: scala.collection.mutable.ListBuffer[ICarbonLock] = ListBuffer() + try { + locksToBeAcquired foreach { + lock => carbonLocks += CarbonLockUtil.getLockObject(carbonTableIdentifier, lock) + } + LOGGER.audit(s"Deleting datamap [$dataMapName] under table [$tableName]") + val carbonTable: Option[CarbonTable] = + catalog.getTableFromMetadataCache(dbName, tableName) match { + case Some(tableMeta) => Some(tableMeta.carbonTable) + case None => try { + Some(catalog.lookupRelation(identifier)(sparkSession) + .asInstanceOf[CarbonRelation].metaData.carbonTable) + } catch { + case ex: NoSuchTableException => + if (!ifExistsSet) { + throw ex + } + None + } + } + if (carbonTable.isDefined && carbonTable.get.getTableInfo.getDataMapSchemaList.size() > 0) { + val dataMapSchema = carbonTable.get.getTableInfo.getDataMapSchemaList.asScala.zipWithIndex. + find(_._1.getDataMapName.equalsIgnoreCase(dataMapName)) + if (dataMapSchema.isDefined) { + + val operationContext = new OperationContext + val dropDataMapPreEvent = + DropDataMapPreEvent( + Some(dataMapSchema.get._1), + ifExistsSet, + sparkSession) + OperationListenerBus.getInstance.fireEvent(dropDataMapPreEvent, operationContext) + + carbonTable.get.getTableInfo.getDataMapSchemaList.remove(dataMapSchema.get._2) + val schemaConverter = new ThriftWrapperSchemaConverterImpl + PreAggregateUtil + .updateSchemaInfo(carbonTable.get, + schemaConverter + .fromWrapperToExternalTableInfo(carbonTable.get.getTableInfo, + dbName, + tableName))(sparkSession) + // fires the event after dropping datamap from main table schema + val dropDataMapPostEvent = + DropDataMapPostEvent( + Some(dataMapSchema.get._1), + ifExistsSet, + sparkSession) + OperationListenerBus.getInstance.fireEvent(dropDataMapPostEvent, operationContext) + } else if (!ifExistsSet) { + throw new Exception( --- End diff -- ok --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150513184 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/CarbonDropDataMapCommand.scala --- @@ -0,0 +1,141 @@ +/* + * 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.datamap + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql.{CarbonEnv, GetDB, Row, SparkSession} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.catalyst.analysis.NoSuchTableException +import org.apache.spark.sql.execution.command.{DataProcessCommand, RunnableCommand, SchemaProcessCommand} +import org.apache.spark.sql.execution.command.preaaggregate.PreAggregateUtil +import org.apache.spark.sql.hive.CarbonRelation + +import org.apache.carbondata.common.logging.{LogService, LogServiceFactory} +import org.apache.carbondata.core.datamap.DataMapStoreManager +import org.apache.carbondata.core.locks.{CarbonLockUtil, ICarbonLock, LockUsage} +import org.apache.carbondata.core.metadata.{AbsoluteTableIdentifier, CarbonTableIdentifier} +import org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl +import org.apache.carbondata.core.metadata.schema.table.CarbonTable +import org.apache.carbondata.events._ + + +case class CarbonDropDataMapCommand( + dataMapName: String, + ifExistsSet: Boolean, + databaseNameOp: Option[String], + tableName: String) + extends RunnableCommand with SchemaProcessCommand with DataProcessCommand { + + override def run(sparkSession: SparkSession): Seq[Row] = { + processSchema(sparkSession) + processData(sparkSession) + } + + override def processSchema(sparkSession: SparkSession): Seq[Row] = { + val LOGGER: LogService = LogServiceFactory.getLogService(this.getClass.getCanonicalName) + val dbName = GetDB.getDatabaseName(databaseNameOp, sparkSession) + val identifier = TableIdentifier(tableName, Option(dbName)) + val carbonTableIdentifier = new CarbonTableIdentifier(dbName, tableName, "") + val locksToBeAcquired = List(LockUsage.METADATA_LOCK) + val carbonEnv = CarbonEnv.getInstance(sparkSession) + val catalog = carbonEnv.carbonMetastore + val tableIdentifier = + AbsoluteTableIdentifier.from(CarbonEnv.getInstance(sparkSession).storePath, + dbName.toLowerCase, tableName.toLowerCase) + catalog.checkSchemasModifiedTimeAndReloadTables(tableIdentifier.getStorePath) + val carbonLocks: scala.collection.mutable.ListBuffer[ICarbonLock] = ListBuffer() + try { + locksToBeAcquired foreach { + lock => carbonLocks += CarbonLockUtil.getLockObject(carbonTableIdentifier, lock) + } + LOGGER.audit(s"Deleting datamap [$dataMapName] under table [$tableName]") + val carbonTable: Option[CarbonTable] = + catalog.getTableFromMetadataCache(dbName, tableName) match { + case Some(tableMeta) => Some(tableMeta.carbonTable) + case None => try { + Some(catalog.lookupRelation(identifier)(sparkSession) + .asInstanceOf[CarbonRelation].metaData.carbonTable) + } catch { + case ex: NoSuchTableException => + if (!ifExistsSet) { + throw ex + } + None + } + } + if (carbonTable.isDefined && carbonTable.get.getTableInfo.getDataMapSchemaList.size() > 0) { + val dataMapSchema = carbonTable.get.getTableInfo.getDataMapSchemaList.asScala.zipWithIndex. + find(_._1.getDataMapName.equalsIgnoreCase(dataMapName)) + if (dataMapSchema.isDefined) { + + val operationContext = new OperationContext + val dropDataMapPreEvent = + DropDataMapPreEvent( + Some(dataMapSchema.get._1), + ifExistsSet, + sparkSession) + OperationListenerBus.getInstance.fireEvent(dropDataMapPreEvent, operationContext) + + carbonTable.get.getTableInfo.getDataMapSchemaList.remove(dataMapSchema.get._2) + val schemaConverter = new ThriftWrapperSchemaConverterImpl + PreAggregateUtil + .updateSchemaInfo(carbonTable.get, --- End diff -- ok --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150513454 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/CarbonDropDataMapCommand.scala --- @@ -0,0 +1,141 @@ +/* + * 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.datamap + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ListBuffer + +import org.apache.spark.sql.{CarbonEnv, GetDB, Row, SparkSession} +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.catalyst.analysis.NoSuchTableException +import org.apache.spark.sql.execution.command.{DataProcessCommand, RunnableCommand, SchemaProcessCommand} +import org.apache.spark.sql.execution.command.preaaggregate.PreAggregateUtil +import org.apache.spark.sql.hive.CarbonRelation + +import org.apache.carbondata.common.logging.{LogService, LogServiceFactory} +import org.apache.carbondata.core.datamap.DataMapStoreManager +import org.apache.carbondata.core.locks.{CarbonLockUtil, ICarbonLock, LockUsage} +import org.apache.carbondata.core.metadata.{AbsoluteTableIdentifier, CarbonTableIdentifier} +import org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl +import org.apache.carbondata.core.metadata.schema.table.CarbonTable +import org.apache.carbondata.events._ + + +case class CarbonDropDataMapCommand( + dataMapName: String, + ifExistsSet: Boolean, + databaseNameOp: Option[String], + tableName: String) + extends RunnableCommand with SchemaProcessCommand with DataProcessCommand { + + override def run(sparkSession: SparkSession): Seq[Row] = { + processSchema(sparkSession) + processData(sparkSession) + } + + override def processSchema(sparkSession: SparkSession): Seq[Row] = { + val LOGGER: LogService = LogServiceFactory.getLogService(this.getClass.getCanonicalName) --- End diff -- ok --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150513579 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/DataMapListeners.scala --- @@ -0,0 +1,71 @@ +/* + * 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.datamap + +import scala.collection.JavaConverters._ + +import org.apache.spark.sql.execution.command.CarbonDropTableCommand + +import org.apache.carbondata.core.metadata.schema.table.DataMapSchema +import org.apache.carbondata.events.{DropDataMapPostEvent, DropTablePostEvent, Event, OperationContext, OperationEventListener} + +object DataMapDropTablePostListener extends OperationEventListener { + + /** + * Called on a specified event occurrence + * + * @param event + */ + override def onEvent(event: Event, operationContext: OperationContext): Unit = { + val dropPostEvent = event.asInstanceOf[DropTablePostEvent] + val carbonTable = dropPostEvent.carbonTable + val sparkSession = dropPostEvent.sparkSession + if (carbonTable.isDefined && carbonTable.get.getTableInfo.getDataMapSchemaList != null && + !carbonTable.get.getTableInfo.getDataMapSchemaList.isEmpty) { + val childSchemas = carbonTable.get.getTableInfo.getDataMapSchemaList + for (childSchema: DataMapSchema <- childSchemas.asScala) { + if (childSchema.getRelationIdentifier != null) { + CarbonDropTableCommand(ifExistsSet = true, --- End diff -- ok --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150514307 --- 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") --- End diff -- we can but since we require to add some code to use programmatical we added sql query. We can take this refactor in future PR as we need to change in other places like load as well. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1489#discussion_r150514886 --- 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 -- Ok, handled --- |
Free forum by Nabble | Edit this page |