VenuReddy2103 opened a new pull request #3938: URL: https://github.com/apache/carbondata/pull/3938 ### Why is this PR needed? Show table extended like command throws java.lang.ArrayIndexOutOfBoundsException ### What changes were proposed in this PR? Instead of carbondata forming the output rows, can call `showTablesCommand.run(sparkSession)`, get the output rows for tables and filter out rows corresponding to MV tables. ### Does this PR introduce any user interface change? - No ### Is any new testcase added? - Yes ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
CarbonDataQA1 commented on pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#issuecomment-695087814 Build Failed with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2388/ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
CarbonDataQA1 commented on pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#issuecomment-695088906 Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4129/ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
CarbonDataQA1 commented on pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#issuecomment-695201015 Build Failed with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2390/ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
CarbonDataQA1 commented on pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#issuecomment-695201285 Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4131/ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
VenuReddy2103 commented on pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#issuecomment-695206077 retest this please ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
CarbonDataQA1 commented on pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#issuecomment-695218349 Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4132/ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
CarbonDataQA1 commented on pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#issuecomment-695218707 Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2391/ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
akashrn5 commented on a change in pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#discussion_r491814518 ########## File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/strategy/DDLHelper.scala ########## @@ -398,9 +398,7 @@ object DDLHelper { } def showTables(showTablesCommand: ShowTablesCommand): Seq[SparkPlan] = { Review comment: is this method really required? can't we just directly call the command class from `DDLStrategy `class? Why to add an intermediate method? ########## File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonShowTablesCommand.scala ########## @@ -18,35 +18,23 @@ package org.apache.spark.sql.execution.command.table import org.apache.spark.sql.{Row, SparkSession} -import org.apache.spark.sql.catalyst.TableIdentifier -import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} -import org.apache.spark.sql.execution.command.MetadataCommand -import org.apache.spark.sql.types.{BooleanType, StringType} +import org.apache.spark.sql.catalyst.expressions.Attribute +import org.apache.spark.sql.execution.command.{MetadataCommand, ShowTablesCommand} -private[sql] case class CarbonShowTablesCommand ( databaseName: Option[String], - tableIdentifierPattern: Option[String]) extends MetadataCommand{ +private[sql] case class CarbonShowTablesCommand(showTablesCommand: ShowTablesCommand) + extends MetadataCommand { - // The result of SHOW TABLES has three columns: database, tableName and isTemporary. - override val output: Seq[Attribute] = { - AttributeReference("database", StringType, nullable = false)() :: - AttributeReference("tableName", StringType, nullable = false)() :: - AttributeReference("isTemporary", BooleanType, nullable = false)() :: Nil - } + override val output: Seq[Attribute] = showTablesCommand.output override def processMetadata(sparkSession: SparkSession): Seq[Row] = { - // Since we need to return a Seq of rows, we will call getTables directly - // instead of calling tables in sparkSession. - val catalog = sparkSession.sessionState.catalog - val db = databaseName.getOrElse(catalog.getCurrentDatabase) - val tables = - tableIdentifierPattern.map(catalog.listTables(db, _)).getOrElse(catalog.listTables(db)) + val rows = showTablesCommand.run(sparkSession) val externalCatalog = sparkSession.sharedState.externalCatalog // this method checks whether the table is mainTable or MV based on property "isVisible" - def isMainTable(tableIdent: TableIdentifier) = { + def isMainTable(db: String, table: String) = { Review comment: move this method after line 46 and also add a comment inside implementation saying what we filter here. ########## File path: integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/ShowTable/TestShowTable.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.testsuite.ShowTable + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException + +/** + * Test class for show tables. + */ +class TestShowTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val dbName = "testshowtable" + override def beforeAll: Unit = { + sql(s"drop database if exists $dbName cascade") + sql(s"create database $dbName") + sql(s"use $dbName") + } + + test("test show tables") { + sql("create table employee(id string, name string) stored as carbondata") + sql("create table employee_part(name string) partitioned by (grade int)") + sql("create index employee_si on table employee(name) as 'carbondata'") + sql("create materialized view employee_mv as select name from employee group by name") + val df = sql("show tables").toDF Review comment: combine rows 41 and 42 and direct do `.collect()` on sql ########## File path: integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/ShowTable/TestShowTable.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.testsuite.ShowTable + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException + +/** + * Test class for show tables. + */ +class TestShowTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val dbName = "testshowtable" + override def beforeAll: Unit = { + sql(s"drop database if exists $dbName cascade") + sql(s"create database $dbName") + sql(s"use $dbName") + } + + test("test show tables") { + sql("create table employee(id string, name string) stored as carbondata") + sql("create table employee_part(name string) partitioned by (grade int)") + sql("create index employee_si on table employee(name) as 'carbondata'") + sql("create materialized view employee_mv as select name from employee group by name") + val df = sql("show tables").toDF + val rows = df.collect() + val schema = rows(0).schema + assert(schema.length == 3) + assert(schema(0).name.equals("database")) + assert(schema(1).name.equals("tableName")) + assert(schema(2).name.equals("isTemporary")) + // show tables query can return views as well. Just validate if expected rows are present + // and unexpected rows are not present. + val expectedRows = Seq(Row(dbName, "employee", false), + Row(dbName, "employee_part", false), + Row(dbName, "employee_si", false)) + val expectedRowsDF = sqlContext.sparkSession + .createDataFrame(sqlContext.sparkContext.makeRDD[Row](expectedRows), schema) + checkAnswer(df.intersect(expectedRowsDF), expectedRows) + // check if mv table is not present + val notExpectedRows = Seq(Row(dbName, "employee_mv", false)) + val notExpectedRowsDF = sqlContext.sparkSession + .createDataFrame(sqlContext.sparkContext.makeRDD[Row](notExpectedRows), schema) + assert(df.intersect(notExpectedRowsDF).count() == 0) + } + + test("test show table extended like") { + sql("create table employee(id string, name string) stored as carbondata") Review comment: can you add one query for non carbon table also? ########## File path: integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/ShowTable/TestShowTable.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.testsuite.ShowTable + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException + +/** + * Test class for show tables. + */ +class TestShowTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val dbName = "testshowtable" + override def beforeAll: Unit = { + sql(s"drop database if exists $dbName cascade") + sql(s"create database $dbName") + sql(s"use $dbName") + } + + test("test show tables") { + sql("create table employee(id string, name string) stored as carbondata") + sql("create table employee_part(name string) partitioned by (grade int)") + sql("create index employee_si on table employee(name) as 'carbondata'") + sql("create materialized view employee_mv as select name from employee group by name") + val df = sql("show tables").toDF + val rows = df.collect() + val schema = rows(0).schema + assert(schema.length == 3) + assert(schema(0).name.equals("database")) + assert(schema(1).name.equals("tableName")) + assert(schema(2).name.equals("isTemporary")) + // show tables query can return views as well. Just validate if expected rows are present + // and unexpected rows are not present. + val expectedRows = Seq(Row(dbName, "employee", false), + Row(dbName, "employee_part", false), + Row(dbName, "employee_si", false)) + val expectedRowsDF = sqlContext.sparkSession Review comment: no need to create the dataframes, just can use `checkanswer` APIs to provide `SQL `and `Seg[Rows[]]`, please modify all places ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
akashrn5 commented on a change in pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#discussion_r491815595 ########## File path: integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/ShowTable/TestShowTable.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.testsuite.ShowTable + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException + +/** + * Test class for show tables. + */ +class TestShowTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val dbName = "testshowtable" + override def beforeAll: Unit = { + sql(s"drop database if exists $dbName cascade") + sql(s"create database $dbName") + sql(s"use $dbName") + } + + test("test show tables") { + sql("create table employee(id string, name string) stored as carbondata") + sql("create table employee_part(name string) partitioned by (grade int)") + sql("create index employee_si on table employee(name) as 'carbondata'") + sql("create materialized view employee_mv as select name from employee group by name") + val df = sql("show tables").toDF + val rows = df.collect() + val schema = rows(0).schema + assert(schema.length == 3) + assert(schema(0).name.equals("database")) + assert(schema(1).name.equals("tableName")) + assert(schema(2).name.equals("isTemporary")) + // show tables query can return views as well. Just validate if expected rows are present + // and unexpected rows are not present. + val expectedRows = Seq(Row(dbName, "employee", false), + Row(dbName, "employee_part", false), + Row(dbName, "employee_si", false)) + val expectedRowsDF = sqlContext.sparkSession Review comment: no need to create the dataframes, just can use `checkanswer` APIs to provide `SQL `and `Seq[Rows[]]`, please modify all places ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
akashrn5 commented on a change in pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#discussion_r491814518 ########## File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/strategy/DDLHelper.scala ########## @@ -398,9 +398,7 @@ object DDLHelper { } def showTables(showTablesCommand: ShowTablesCommand): Seq[SparkPlan] = { Review comment: is this method really required? can't we just directly call the command class from `DDLStrategy `class? Why to add an intermediate method? ########## File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonShowTablesCommand.scala ########## @@ -18,35 +18,23 @@ package org.apache.spark.sql.execution.command.table import org.apache.spark.sql.{Row, SparkSession} -import org.apache.spark.sql.catalyst.TableIdentifier -import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} -import org.apache.spark.sql.execution.command.MetadataCommand -import org.apache.spark.sql.types.{BooleanType, StringType} +import org.apache.spark.sql.catalyst.expressions.Attribute +import org.apache.spark.sql.execution.command.{MetadataCommand, ShowTablesCommand} -private[sql] case class CarbonShowTablesCommand ( databaseName: Option[String], - tableIdentifierPattern: Option[String]) extends MetadataCommand{ +private[sql] case class CarbonShowTablesCommand(showTablesCommand: ShowTablesCommand) + extends MetadataCommand { - // The result of SHOW TABLES has three columns: database, tableName and isTemporary. - override val output: Seq[Attribute] = { - AttributeReference("database", StringType, nullable = false)() :: - AttributeReference("tableName", StringType, nullable = false)() :: - AttributeReference("isTemporary", BooleanType, nullable = false)() :: Nil - } + override val output: Seq[Attribute] = showTablesCommand.output override def processMetadata(sparkSession: SparkSession): Seq[Row] = { - // Since we need to return a Seq of rows, we will call getTables directly - // instead of calling tables in sparkSession. - val catalog = sparkSession.sessionState.catalog - val db = databaseName.getOrElse(catalog.getCurrentDatabase) - val tables = - tableIdentifierPattern.map(catalog.listTables(db, _)).getOrElse(catalog.listTables(db)) + val rows = showTablesCommand.run(sparkSession) val externalCatalog = sparkSession.sharedState.externalCatalog // this method checks whether the table is mainTable or MV based on property "isVisible" - def isMainTable(tableIdent: TableIdentifier) = { + def isMainTable(db: String, table: String) = { Review comment: move this method after line 46 and also add a comment inside implementation saying what we filter here. ########## File path: integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/ShowTable/TestShowTable.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.testsuite.ShowTable + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException + +/** + * Test class for show tables. + */ +class TestShowTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val dbName = "testshowtable" + override def beforeAll: Unit = { + sql(s"drop database if exists $dbName cascade") + sql(s"create database $dbName") + sql(s"use $dbName") + } + + test("test show tables") { + sql("create table employee(id string, name string) stored as carbondata") + sql("create table employee_part(name string) partitioned by (grade int)") + sql("create index employee_si on table employee(name) as 'carbondata'") + sql("create materialized view employee_mv as select name from employee group by name") + val df = sql("show tables").toDF Review comment: combine rows 41 and 42 and direct do `.collect()` on sql ########## File path: integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/ShowTable/TestShowTable.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.testsuite.ShowTable + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException + +/** + * Test class for show tables. + */ +class TestShowTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val dbName = "testshowtable" + override def beforeAll: Unit = { + sql(s"drop database if exists $dbName cascade") + sql(s"create database $dbName") + sql(s"use $dbName") + } + + test("test show tables") { + sql("create table employee(id string, name string) stored as carbondata") + sql("create table employee_part(name string) partitioned by (grade int)") + sql("create index employee_si on table employee(name) as 'carbondata'") + sql("create materialized view employee_mv as select name from employee group by name") + val df = sql("show tables").toDF + val rows = df.collect() + val schema = rows(0).schema + assert(schema.length == 3) + assert(schema(0).name.equals("database")) + assert(schema(1).name.equals("tableName")) + assert(schema(2).name.equals("isTemporary")) + // show tables query can return views as well. Just validate if expected rows are present + // and unexpected rows are not present. + val expectedRows = Seq(Row(dbName, "employee", false), + Row(dbName, "employee_part", false), + Row(dbName, "employee_si", false)) + val expectedRowsDF = sqlContext.sparkSession + .createDataFrame(sqlContext.sparkContext.makeRDD[Row](expectedRows), schema) + checkAnswer(df.intersect(expectedRowsDF), expectedRows) + // check if mv table is not present + val notExpectedRows = Seq(Row(dbName, "employee_mv", false)) + val notExpectedRowsDF = sqlContext.sparkSession + .createDataFrame(sqlContext.sparkContext.makeRDD[Row](notExpectedRows), schema) + assert(df.intersect(notExpectedRowsDF).count() == 0) + } + + test("test show table extended like") { + sql("create table employee(id string, name string) stored as carbondata") Review comment: can you add one query for non carbon table also? ########## File path: integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/ShowTable/TestShowTable.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.testsuite.ShowTable + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException + +/** + * Test class for show tables. + */ +class TestShowTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val dbName = "testshowtable" + override def beforeAll: Unit = { + sql(s"drop database if exists $dbName cascade") + sql(s"create database $dbName") + sql(s"use $dbName") + } + + test("test show tables") { + sql("create table employee(id string, name string) stored as carbondata") + sql("create table employee_part(name string) partitioned by (grade int)") + sql("create index employee_si on table employee(name) as 'carbondata'") + sql("create materialized view employee_mv as select name from employee group by name") + val df = sql("show tables").toDF + val rows = df.collect() + val schema = rows(0).schema + assert(schema.length == 3) + assert(schema(0).name.equals("database")) + assert(schema(1).name.equals("tableName")) + assert(schema(2).name.equals("isTemporary")) + // show tables query can return views as well. Just validate if expected rows are present + // and unexpected rows are not present. + val expectedRows = Seq(Row(dbName, "employee", false), + Row(dbName, "employee_part", false), + Row(dbName, "employee_si", false)) + val expectedRowsDF = sqlContext.sparkSession Review comment: no need to create the dataframes, just can use `checkanswer` APIs to provide `SQL `and `Seg[Rows[]]`, please modify all places ########## File path: integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/ShowTable/TestShowTable.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.testsuite.ShowTable + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException + +/** + * Test class for show tables. + */ +class TestShowTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val dbName = "testshowtable" + override def beforeAll: Unit = { + sql(s"drop database if exists $dbName cascade") + sql(s"create database $dbName") + sql(s"use $dbName") + } + + test("test show tables") { + sql("create table employee(id string, name string) stored as carbondata") + sql("create table employee_part(name string) partitioned by (grade int)") + sql("create index employee_si on table employee(name) as 'carbondata'") + sql("create materialized view employee_mv as select name from employee group by name") + val df = sql("show tables").toDF + val rows = df.collect() + val schema = rows(0).schema + assert(schema.length == 3) + assert(schema(0).name.equals("database")) + assert(schema(1).name.equals("tableName")) + assert(schema(2).name.equals("isTemporary")) + // show tables query can return views as well. Just validate if expected rows are present + // and unexpected rows are not present. + val expectedRows = Seq(Row(dbName, "employee", false), + Row(dbName, "employee_part", false), + Row(dbName, "employee_si", false)) + val expectedRowsDF = sqlContext.sparkSession Review comment: no need to create the dataframes, just can use `checkanswer` APIs to provide `SQL `and `Seq[Rows[]]`, please modify all places ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
VenuReddy2103 commented on a change in pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#discussion_r492609629 ########## File path: integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/ShowTable/TestShowTable.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.testsuite.ShowTable + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException + +/** + * Test class for show tables. + */ +class TestShowTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val dbName = "testshowtable" + override def beforeAll: Unit = { + sql(s"drop database if exists $dbName cascade") + sql(s"create database $dbName") + sql(s"use $dbName") + } + + test("test show tables") { + sql("create table employee(id string, name string) stored as carbondata") + sql("create table employee_part(name string) partitioned by (grade int)") + sql("create index employee_si on table employee(name) as 'carbondata'") + sql("create materialized view employee_mv as select name from employee group by name") + val df = sql("show tables").toDF + val rows = df.collect() + val schema = rows(0).schema + assert(schema.length == 3) + assert(schema(0).name.equals("database")) + assert(schema(1).name.equals("tableName")) + assert(schema(2).name.equals("isTemporary")) + // show tables query can return views as well. Just validate if expected rows are present + // and unexpected rows are not present. + val expectedRows = Seq(Row(dbName, "employee", false), + Row(dbName, "employee_part", false), + Row(dbName, "employee_si", false)) + val expectedRowsDF = sqlContext.sparkSession + .createDataFrame(sqlContext.sparkContext.makeRDD[Row](expectedRows), schema) + checkAnswer(df.intersect(expectedRowsDF), expectedRows) + // check if mv table is not present + val notExpectedRows = Seq(Row(dbName, "employee_mv", false)) + val notExpectedRowsDF = sqlContext.sparkSession + .createDataFrame(sqlContext.sparkContext.makeRDD[Row](notExpectedRows), schema) + assert(df.intersect(notExpectedRowsDF).count() == 0) + } + + test("test show table extended like") { + sql("create table employee(id string, name string) stored as carbondata") Review comment: employee_part table is non carbon table ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
VenuReddy2103 commented on a change in pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#discussion_r492617535 ########## File path: integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/ShowTable/TestShowTable.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.testsuite.ShowTable + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException + +/** + * Test class for show tables. + */ +class TestShowTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val dbName = "testshowtable" + override def beforeAll: Unit = { + sql(s"drop database if exists $dbName cascade") + sql(s"create database $dbName") + sql(s"use $dbName") + } + + test("test show tables") { + sql("create table employee(id string, name string) stored as carbondata") + sql("create table employee_part(name string) partitioned by (grade int)") + sql("create index employee_si on table employee(name) as 'carbondata'") + sql("create materialized view employee_mv as select name from employee group by name") + val df = sql("show tables").toDF Review comment: Had done that because show tables returns views as well. Have refactored it now such that we intersection of received rows and expected rows to check. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
VenuReddy2103 commented on a change in pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#discussion_r492617780 ########## File path: integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/ShowTable/TestShowTable.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.testsuite.ShowTable + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException + +/** + * Test class for show tables. + */ +class TestShowTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val dbName = "testshowtable" + override def beforeAll: Unit = { + sql(s"drop database if exists $dbName cascade") + sql(s"create database $dbName") + sql(s"use $dbName") + } + + test("test show tables") { + sql("create table employee(id string, name string) stored as carbondata") + sql("create table employee_part(name string) partitioned by (grade int)") + sql("create index employee_si on table employee(name) as 'carbondata'") + sql("create materialized view employee_mv as select name from employee group by name") + val df = sql("show tables").toDF + val rows = df.collect() + val schema = rows(0).schema + assert(schema.length == 3) + assert(schema(0).name.equals("database")) + assert(schema(1).name.equals("tableName")) + assert(schema(2).name.equals("isTemporary")) + // show tables query can return views as well. Just validate if expected rows are present + // and unexpected rows are not present. + val expectedRows = Seq(Row(dbName, "employee", false), + Row(dbName, "employee_part", false), + Row(dbName, "employee_si", false)) + val expectedRowsDF = sqlContext.sparkSession Review comment: have refactored it now. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
VenuReddy2103 commented on a change in pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#discussion_r492619063 ########## File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/strategy/DDLHelper.scala ########## @@ -398,9 +398,7 @@ object DDLHelper { } def showTables(showTablesCommand: ShowTablesCommand): Seq[SparkPlan] = { Review comment: Not required. Have removed it ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
VenuReddy2103 commented on a change in pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#discussion_r492626070 ########## File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonShowTablesCommand.scala ########## @@ -18,35 +18,23 @@ package org.apache.spark.sql.execution.command.table import org.apache.spark.sql.{Row, SparkSession} -import org.apache.spark.sql.catalyst.TableIdentifier -import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} -import org.apache.spark.sql.execution.command.MetadataCommand -import org.apache.spark.sql.types.{BooleanType, StringType} +import org.apache.spark.sql.catalyst.expressions.Attribute +import org.apache.spark.sql.execution.command.{MetadataCommand, ShowTablesCommand} -private[sql] case class CarbonShowTablesCommand ( databaseName: Option[String], - tableIdentifierPattern: Option[String]) extends MetadataCommand{ +private[sql] case class CarbonShowTablesCommand(showTablesCommand: ShowTablesCommand) + extends MetadataCommand { - // The result of SHOW TABLES has three columns: database, tableName and isTemporary. - override val output: Seq[Attribute] = { - AttributeReference("database", StringType, nullable = false)() :: - AttributeReference("tableName", StringType, nullable = false)() :: - AttributeReference("isTemporary", BooleanType, nullable = false)() :: Nil - } + override val output: Seq[Attribute] = showTablesCommand.output override def processMetadata(sparkSession: SparkSession): Seq[Row] = { - // Since we need to return a Seq of rows, we will call getTables directly - // instead of calling tables in sparkSession. - val catalog = sparkSession.sessionState.catalog - val db = databaseName.getOrElse(catalog.getCurrentDatabase) - val tables = - tableIdentifierPattern.map(catalog.listTables(db, _)).getOrElse(catalog.listTables(db)) + val rows = showTablesCommand.run(sparkSession) val externalCatalog = sparkSession.sharedState.externalCatalog // this method checks whether the table is mainTable or MV based on property "isVisible" - def isMainTable(tableIdent: TableIdentifier) = { + def isMainTable(db: String, table: String) = { Review comment: I think, current one looks ok. Because, Filtered rows are implicitly returned at line 46. If we move this isMainTable() method def to after line 46, need to take filtered rows to temp and use it retured. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
CarbonDataQA1 commented on pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#issuecomment-696663738 Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4170/ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
CarbonDataQA1 commented on pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#issuecomment-696666764 Build Failed with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2427/ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
VenuReddy2103 commented on pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#issuecomment-696678341 retest this please ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
CarbonDataQA1 commented on pull request #3938: URL: https://github.com/apache/carbondata/pull/3938#issuecomment-696728481 Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4172/ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
Free forum by Nabble | Edit this page |