[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-02-07 Thread xubo245
Github user xubo245 commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r166848593
  
--- Diff: 
integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggCreateCommand.scala
 ---
@@ -216,6 +216,20 @@ class TestPreAggCreateCommand extends QueryTest with 
BeforeAndAfterAll {
   }
 
   val timeSeries = TIMESERIES.toString
+  test("remove agg tables from show table command") {
+sql("DROP TABLE IF EXISTS tbl_1")
+sql("DROP TABLE IF EXISTS sparktable")
+sql("create table if not exists  tbl_1(imei string,age int,mac string 
,prodate timestamp,update timestamp,gamepoint double,contrid double) stored by 
'carbondata' ")
+sql("create table if not exists sparktable(a int,b string)")
+sql(
+  s"""create datamap preagg_sum on table tbl_1 using 'preaggregate' as 
select mac,avg(age) from tbl_1 group by mac"""
+.stripMargin)
+sql(
+  "create datamap agg2 on table tbl_1 using 'preaggregate' 
DMPROPERTIES ('timeseries" +
+  ".eventTime'='prodate', 
'timeseries.hierarchy'='hour=1,day=1,month=1,year=1') as select prodate," +
--- End diff --

I fix it on https://github.com/apache/carbondata/pull/1929, please review 
it @BJangir @jackylk @ravipesala @sraghunandan 


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-02-07 Thread xubo245
Github user xubo245 commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r166847806
  
--- Diff: 
integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateDrop.scala
 ---
@@ -46,8 +46,9 @@ class TestPreAggregateDrop extends QueryTest with 
BeforeAndAfterAll {
   " a,sum(c) from maintable group by a")
 sql("drop datamap if exists preagg2 on table maintable")
 val showTables = sql("show tables")
+val showdatamaps =sql("show datamap on table maintable")
 checkExistence(showTables, false, "maintable_preagg2")
--- End diff --

for example:

  test("dropping 1 aggregate table should not drop others") {
 sql(
   "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" +
   " a,sum(c) from maintable group by a")
 sql("drop datamap if exists preagg2 on table maintable")
 val showTables = sql("show tables")
 checkExistence(showTables, false, "maintable_preagg2")

showTables will always not contain maintable_preagg2, so we need adapt new 
show table function. There are some test case need check again.  @BJangir 
@jackylk @chenliang613 @sraghunandan @ravipesala 


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-02-07 Thread xubo245
Github user xubo245 commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r166847284
  
--- Diff: 
integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateDrop.scala
 ---
@@ -46,8 +46,9 @@ class TestPreAggregateDrop extends QueryTest with 
BeforeAndAfterAll {
   " a,sum(c) from maintable group by a")
 sql("drop datamap if exists preagg2 on table maintable")
 val showTables = sql("show tables")
+val showdatamaps =sql("show datamap on table maintable")
 checkExistence(showTables, false, "maintable_preagg2")
--- End diff --

this test case is invalid after you change the function of "show tables


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-02-02 Thread xubo245
Github user xubo245 commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r165807488
  
--- Diff: 
integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggCreateCommand.scala
 ---
@@ -216,6 +216,20 @@ class TestPreAggCreateCommand extends QueryTest with 
BeforeAndAfterAll {
   }
 
   val timeSeries = TIMESERIES.toString
+  test("remove agg tables from show table command") {
+sql("DROP TABLE IF EXISTS tbl_1")
+sql("DROP TABLE IF EXISTS sparktable")
+sql("create table if not exists  tbl_1(imei string,age int,mac string 
,prodate timestamp,update timestamp,gamepoint double,contrid double) stored by 
'carbondata' ")
+sql("create table if not exists sparktable(a int,b string)")
+sql(
+  s"""create datamap preagg_sum on table tbl_1 using 'preaggregate' as 
select mac,avg(age) from tbl_1 group by mac"""
+.stripMargin)
+sql(
+  "create datamap agg2 on table tbl_1 using 'preaggregate' 
DMPROPERTIES ('timeseries" +
+  ".eventTime'='prodate', 
'timeseries.hierarchy'='hour=1,day=1,month=1,year=1') as select prodate," +
--- End diff --

we don't support create timeseries table like this now : 
'timeseries.eventTime'='prodate', 'timeseries.hierarchy'


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-02-02 Thread xubo245
Github user xubo245 commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r165807476
  
--- Diff: 
integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggCreateCommand.scala
 ---
@@ -270,6 +284,28 @@ class TestPreAggCreateCommand extends QueryTest with 
BeforeAndAfterAll {
 sql("DROP DATAMAP IF EXISTS agg0 ON TABLE maintable")
   }
 
+  test("remove  agg tables from show table command") {
+sql("DROP TABLE IF EXISTS tbl_1")
+sql("create table if not exists  tbl_1(imei string,age int,mac string 
,prodate timestamp,update timestamp,gamepoint double,contrid double) stored by 
'carbondata' ")
+sql("create datamap agg1 on table tbl_1 using 'preaggregate' as select 
mac, sum(age) from tbl_1 group by mac")
+sql("create table if not exists  sparktable(imei string,age int,mac 
string ,prodate timestamp,update timestamp,gamepoint double,contrid double) ")
+checkExistence(sql("show tables"), false, "tbl_1_agg1")
+checkExistence(sql("show tables"), true, "sparktable","tbl_1")
+  }
+
+
+  test("remove TimeSeries agg tables from show table command") {
+sql("DROP TABLE IF EXISTS tbl_1")
+sql("create table if not exists  tbl_1(imei string,age int,mac string 
,prodate timestamp,update timestamp,gamepoint double,contrid double) stored by 
'carbondata' ")
+sql(
+  "create datamap agg2 on table tbl_1 using 'preaggregate' 
DMPROPERTIES ('timeseries" +
--- End diff --

we don't support create timeseries table like this :  
'timeseries.eventTime'='prodate', 'timeseries.hierarchy'


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-02-01 Thread xubo245
Github user xubo245 commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r165567560
  
--- Diff: 
integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateDrop.scala
 ---
@@ -84,7 +86,8 @@ class TestPreAggregateDrop extends QueryTest with 
BeforeAndAfterAll {
 sql("create datamap preagg_same1 on table maintable using 
'preaggregate' as select" +
 " a,sum(c) from maintable group by a")
 showTables = sql("show tables")
--- End diff --

remove this line


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-02-01 Thread BJangir
Github user BJangir closed the pull request at:

https://github.com/apache/carbondata/pull/1878


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-01-31 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r165037118
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonShowTablesCommand.scala
 ---
@@ -0,0 +1,78 @@
+/*
+ * 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.table
+
+import scala.collection.JavaConverters._
+
+import org.apache.spark.sql.{CarbonEnv, 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}
+
+
+private[sql] case class CarbonShowTablesCommand ( databaseName: 
Option[String],
+tableIdentifierPattern: Option[String])  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 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.
+// filterDataMaps Method is to Filter the Table.
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+var tables =
+  tableIdentifierPattern.map(catalog.listTables(db, 
_)).getOrElse(catalog.listTables(db))
+tables = filterDataMaps(tables, sparkSession)
+tables.map { tableIdent =>
+  val isTemp = catalog.isTemporaryTable(tableIdent)
+  Row(tableIdent.database.getOrElse("default"), tableIdent.table, 
isTemp)
+}
+  }
+
+  /**
+   *
+   * @param tables tableIdnetifers
+   * @param sparkSession sparksession
+   * @return  Tables after filter datamap tables
+   */
+  private def filterDataMaps(tables: Seq[TableIdentifier],
+  sparkSession: SparkSession): Seq[TableIdentifier] = {
+// Filter carbon Tables then get CarbonTable and getDataMap List and 
filter the same
+// as of now 2 times lookup is happening(filter  carbon table 
,getDataMapList)
+//  add another PR (CARBONDATA-2103) to improve  with 1 lookup
+val allDatamapTable = tables.filter(table => {
--- End diff --

the code style is not changed yet


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-01-31 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r165037072
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonShowTablesCommand.scala
 ---
@@ -0,0 +1,78 @@
+/*
+ * 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.table
+
+import scala.collection.JavaConverters._
+
+import org.apache.spark.sql.{CarbonEnv, 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}
+
+
+private[sql] case class CarbonShowTablesCommand ( databaseName: 
Option[String],
+tableIdentifierPattern: Option[String])  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 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.
+// filterDataMaps Method is to Filter the Table.
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+var tables =
+  tableIdentifierPattern.map(catalog.listTables(db, 
_)).getOrElse(catalog.listTables(db))
+tables = filterDataMaps(tables, sparkSession)
+tables.map { tableIdent =>
+  val isTemp = catalog.isTemporaryTable(tableIdent)
+  Row(tableIdent.database.getOrElse("default"), tableIdent.table, 
isTemp)
+}
+  }
+
+  /**
+   *
+   * @param tables tableIdnetifers
+   * @param sparkSession sparksession
+   * @return  Tables after filter datamap tables
+   */
+  private def filterDataMaps(tables: Seq[TableIdentifier],
+  sparkSession: SparkSession): Seq[TableIdentifier] = {
+// Filter carbon Tables then get CarbonTable and getDataMap List and 
filter the same
+// as of now 2 times lookup is happening(filter  carbon table 
,getDataMapList)
+//  add another PR (CARBONDATA-2103) to improve  with 1 lookup
--- End diff --

change to `TODO`


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-01-30 Thread BJangir
Github user BJangir commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r164813794
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/ShowTablesCommand.scala
 ---
@@ -0,0 +1,72 @@
+/*
+ * 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.table
+
+import scala.collection.JavaConverters._
+
+import org.apache.spark.sql.{CarbonEnv, 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}
+
+
+private[sql] case class ShowTablesCommand ( databaseName: Option[String],
--- End diff --

OK


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-01-29 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r164654501
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/ShowTablesCommand.scala
 ---
@@ -0,0 +1,72 @@
+/*
+ * 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.table
+
+import scala.collection.JavaConverters._
+
+import org.apache.spark.sql.{CarbonEnv, 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}
+
+
+private[sql] case class ShowTablesCommand ( databaseName: Option[String],
+tableIdentifierPattern: Option[String])  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 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.
+// filterDataMaps Method is to Filter the Table.
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+var tables =
+  tableIdentifierPattern.map(catalog.listTables(db, 
_)).getOrElse(catalog.listTables(db))
+tables = filterDataMaps(tables, sparkSession)
+tables.map { tableIdent =>
+  val isTemp = catalog.isTemporaryTable(tableIdent)
+  Row(tableIdent.database.getOrElse(""), tableIdent.table, isTemp)
+}
+  }
+
+  private def filterDataMaps(tables: Seq[TableIdentifier],
+  sparkSession: SparkSession): Seq[TableIdentifier] = {
+// Filter carbon Tables then get CarbonTable and getDataMap List and 
filter the same
+// as of now 2 times lookup is happening(filter  carbon table 
,getDataMapList)
+//  add another PR to improve  with 1 lookup
+val allDatamapTable = tables.filter(tbs => {
--- End diff --

`tables.filter(tbs => {` change to 
`tables.filter { table =>`


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-01-29 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r164654398
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/ShowTablesCommand.scala
 ---
@@ -0,0 +1,72 @@
+/*
+ * 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.table
+
+import scala.collection.JavaConverters._
+
+import org.apache.spark.sql.{CarbonEnv, 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}
+
+
+private[sql] case class ShowTablesCommand ( databaseName: Option[String],
+tableIdentifierPattern: Option[String])  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 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.
+// filterDataMaps Method is to Filter the Table.
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+var tables =
+  tableIdentifierPattern.map(catalog.listTables(db, 
_)).getOrElse(catalog.listTables(db))
+tables = filterDataMaps(tables, sparkSession)
+tables.map { tableIdent =>
+  val isTemp = catalog.isTemporaryTable(tableIdent)
+  Row(tableIdent.database.getOrElse(""), tableIdent.table, isTemp)
+}
+  }
+
+  private def filterDataMaps(tables: Seq[TableIdentifier],
+  sparkSession: SparkSession): Seq[TableIdentifier] = {
+// Filter carbon Tables then get CarbonTable and getDataMap List and 
filter the same
+// as of now 2 times lookup is happening(filter  carbon table 
,getDataMapList)
+//  add another PR to improve  with 1 lookup
--- End diff --

change  to TODO
and add the JIRA number here


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-01-29 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r164654277
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/ShowTablesCommand.scala
 ---
@@ -0,0 +1,72 @@
+/*
+ * 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.table
+
+import scala.collection.JavaConverters._
+
+import org.apache.spark.sql.{CarbonEnv, 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}
+
+
+private[sql] case class ShowTablesCommand ( databaseName: Option[String],
+tableIdentifierPattern: Option[String])  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 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.
+// filterDataMaps Method is to Filter the Table.
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+var tables =
+  tableIdentifierPattern.map(catalog.listTables(db, 
_)).getOrElse(catalog.listTables(db))
+tables = filterDataMaps(tables, sparkSession)
+tables.map { tableIdent =>
+  val isTemp = catalog.isTemporaryTable(tableIdent)
+  Row(tableIdent.database.getOrElse(""), tableIdent.table, isTemp)
+}
+  }
+
+  private def filterDataMaps(tables: Seq[TableIdentifier],
--- End diff --

please add comment


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-01-29 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r164653281
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/ShowTablesCommand.scala
 ---
@@ -0,0 +1,72 @@
+/*
+ * 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.table
+
+import scala.collection.JavaConverters._
+
+import org.apache.spark.sql.{CarbonEnv, 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}
+
+
+private[sql] case class ShowTablesCommand ( databaseName: Option[String],
+tableIdentifierPattern: Option[String])  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 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.
+// filterDataMaps Method is to Filter the Table.
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+var tables =
+  tableIdentifierPattern.map(catalog.listTables(db, 
_)).getOrElse(catalog.listTables(db))
+tables = filterDataMaps(tables, sparkSession)
+tables.map { tableIdent =>
+  val isTemp = catalog.isTemporaryTable(tableIdent)
+  Row(tableIdent.database.getOrElse(""), tableIdent.table, isTemp)
--- End diff --

`tableIdent.database.getOrElse("")` is not right, default database is 
`default`


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-01-29 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r164653059
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/ShowTablesCommand.scala
 ---
@@ -0,0 +1,72 @@
+/*
+ * 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.table
+
+import scala.collection.JavaConverters._
+
+import org.apache.spark.sql.{CarbonEnv, 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}
+
+
+private[sql] case class ShowTablesCommand ( databaseName: Option[String],
+tableIdentifierPattern: Option[String])  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 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.
+// filterDataMaps Method is to Filter the Table.
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
--- End diff --

Use `CarbonEnv.getDatabaseName` instead


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-01-29 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r164652985
  
--- Diff: 
integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggCreateCommand.scala
 ---
@@ -212,6 +212,21 @@ class TestPreAggCreateCommand extends QueryTest with 
BeforeAndAfterAll {
 sql("drop datamap agg0 on table maintable")
   }
 
+  test("remove agg tables from show table command") {
+sql("DROP TABLE IF EXISTS tbl_1")
+sql("DROP TABLE IF EXISTS sparktable")
+sql("create table if not exists  tbl_1(imei string,age int,mac string 
,prodate timestamp,update timestamp,gamepoint double,contrid double) stored by 
'carbondata' ")
+sql("create table if not exists sparktable(a int,b string)")
+sql(
+  s"""create datamap preagg_sum on table tbl_1 using 'preaggregate' as 
select mac,avg(age) from tbl_1 group by mac"""
+.stripMargin)
+sql(
+  "create datamap agg2 on table tbl_1 using 'preaggregate' 
DMPROPERTIES ('timeseries" +
--- End diff --

Please split this testcase into two testcases, one for preaggregation 
datamap, another for time series datamap


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-01-29 Thread jackylk
Github user jackylk commented on a diff in the pull request:

https://github.com/apache/carbondata/pull/1878#discussion_r164652631
  
--- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/ShowTablesCommand.scala
 ---
@@ -0,0 +1,72 @@
+/*
+ * 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.table
+
+import scala.collection.JavaConverters._
+
+import org.apache.spark.sql.{CarbonEnv, 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}
+
+
+private[sql] case class ShowTablesCommand ( databaseName: Option[String],
--- End diff --

Change to `CarbonShowTablesCommand` like other commands


---


[GitHub] carbondata pull request #1878: [CARBONDATA-2094] Filter DataMap Tables in Sh...

2018-01-29 Thread BJangir
GitHub user BJangir opened a pull request:

https://github.com/apache/carbondata/pull/1878

[CARBONDATA-2094] Filter DataMap Tables in Show Table Command

Currently Show Table command shows datamap tables (agg tablels) but show 
table command should not show aggregate tables.

Solution :- Handle "show table "command in carbon side and Filter the 
datamap table and return rest of  the tables.

Be sure to do all of the following checklist to help us incorporate 
your contribution quickly and easily:

 - [ ] Any interfaces changed? NO
 
 - [ ] Any backward compatibility impacted?
 NO
 - [ ] Document update required?
NO
 - [ ] Testing done
Please provide details on 
- Whether new unit test cases have been added or why no new tests 
are required?
UI Added
- How it is tested? Please attach test report.
UI added
- Is it a performance related change? Please attach the performance 
test report.
 NA
- Any additional information to help reviewers in testing this change.
  NA 
 - [ ] For large changes, please consider breaking it into sub-tasks under 
an umbrella JIRA. 
NA


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/BJangir/incubator-carbondata block_agg_display

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/carbondata/pull/1878.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1878


commit c5caa22a7cc6c164ac37cfe142c6516a4933b5bf
Author: BJangir 
Date:   2018-01-29T18:16:56Z

[CARBONDATA-2094] Filter DataMap Tables in Show Table Command




---