Repository: carbondata Updated Branches: refs/heads/master 3c5d10f39 -> 4eb37240f
[CARBONDATA-1585][Streaming] Describe formatted command should show stream property Describe formatted command should show stream property This closes #1634 Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/4eb37240 Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/4eb37240 Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/4eb37240 Branch: refs/heads/master Commit: 4eb37240f252611f3ee82bea8f3f993400eebb5b Parents: 3c5d10f Author: QiangCai <[email protected]> Authored: Fri Dec 8 11:32:17 2017 +0800 Committer: Jacky Li <[email protected]> Committed: Tue Dec 12 14:47:20 2017 +0800 ---------------------------------------------------------------------- .../TestAlterTableWithTableComment.scala | 10 +++++----- .../TestCreateTableWithTableComment.scala | 4 ++-- .../describeTable/TestDescribeTable.scala | 2 +- .../table/CarbonDescribeFormattedCommand.scala | 21 +++++++++++--------- .../TestStreamingTableOperation.scala | 13 ++++++++++++ 5 files changed, 33 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/carbondata/blob/4eb37240/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestAlterTableWithTableComment.scala ---------------------------------------------------------------------- diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestAlterTableWithTableComment.scala b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestAlterTableWithTableComment.scala index b01fe4f..75d9bf9 100644 --- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestAlterTableWithTableComment.scala +++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestAlterTableWithTableComment.scala @@ -45,7 +45,7 @@ class TestAlterTableWithTableComment extends QueryTest with BeforeAndAfterAll { val create_result = sql("describe formatted alterTableWithTableComment") - checkExistence(create_result, true, "Comment:") + checkExistence(create_result, true, "Comment") checkExistence(create_result, false, "This is table comment") sql( @@ -59,7 +59,7 @@ class TestAlterTableWithTableComment extends QueryTest with BeforeAndAfterAll { val alter_result = sql("describe formatted alterTableWithTableComment") - checkExistence(alter_result, true, "Comment:") + checkExistence(alter_result, true, "Comment") checkExistence(alter_result, true, "This table comment is added by alter table") } @@ -86,7 +86,7 @@ class TestAlterTableWithTableComment extends QueryTest with BeforeAndAfterAll { val alter_result = sql("describe formatted alterTableWithoutTableComment") - checkExistence(alter_result, true, "Comment:") + checkExistence(alter_result, true, "Comment") checkExistence(alter_result, true, "This table comment is modified by alter table set") } @@ -104,7 +104,7 @@ class TestAlterTableWithTableComment extends QueryTest with BeforeAndAfterAll { val create_result = sql("describe formatted alterTableUnsetTableComment") - checkExistence(create_result, true, "Comment:") + checkExistence(create_result, true, "Comment") checkExistence(create_result, true, "This is table comment") sql( @@ -116,7 +116,7 @@ class TestAlterTableWithTableComment extends QueryTest with BeforeAndAfterAll { val alter_result = sql("describe formatted alterTableUnsetTableComment") - checkExistence(alter_result, true, "Comment:") + checkExistence(alter_result, true, "Comment") checkExistence(alter_result, false, "This is table comment") } http://git-wip-us.apache.org/repos/asf/carbondata/blob/4eb37240/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableWithTableComment.scala ---------------------------------------------------------------------- diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableWithTableComment.scala b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableWithTableComment.scala index 86b8327..5e5ee31 100644 --- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableWithTableComment.scala +++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableWithTableComment.scala @@ -45,7 +45,7 @@ class TestCreateTableWithTableComment extends QueryTest with BeforeAndAfterAll { val result = sql("describe formatted withTableComment") - checkExistence(result, true, "Comment:") + checkExistence(result, true, "Comment") checkExistence(result, true, "This table has table comment") } @@ -62,7 +62,7 @@ class TestCreateTableWithTableComment extends QueryTest with BeforeAndAfterAll { val result = sql("describe formatted withoutTableComment") - checkExistence(result, true, "Comment:") + checkExistence(result, true, "Comment") checkExistence(result, false, "This table has table comment") } http://git-wip-us.apache.org/repos/asf/carbondata/blob/4eb37240/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/describeTable/TestDescribeTable.scala ---------------------------------------------------------------------- diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/describeTable/TestDescribeTable.scala b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/describeTable/TestDescribeTable.scala index 6c32ed4..b2a1120 100644 --- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/describeTable/TestDescribeTable.scala +++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/describeTable/TestDescribeTable.scala @@ -40,7 +40,7 @@ class TestDescribeTable extends QueryTest with BeforeAndAfterAll { test("test describe formatted table") { checkExistence(sql("DESC FORMATTED Desc1"), true, - "Table Block Size :") + "Table Block Size") } override def afterAll: Unit = { http://git-wip-us.apache.org/repos/asf/carbondata/blob/4eb37240/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonDescribeFormattedCommand.scala ---------------------------------------------------------------------- diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonDescribeFormattedCommand.scala b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonDescribeFormattedCommand.scala index aec1e93..d0baa61 100644 --- a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonDescribeFormattedCommand.scala +++ b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonDescribeFormattedCommand.scala @@ -99,28 +99,31 @@ private[sql] case class CarbonDescribeFormattedCommand( colProps.toString() } results ++= Seq(("", "", ""), ("##Detailed Table Information", "", "")) - results ++= Seq(("Database Name: ", relation.carbonTable.getDatabaseName, "") + results ++= Seq(("Database Name", relation.carbonTable.getDatabaseName, "") ) - results ++= Seq(("Table Name: ", relation.carbonTable.getTableName, "")) - results ++= Seq(("CARBON Store Path: ", CarbonProperties.getStorePath, "")) + results ++= Seq(("Table Name", relation.carbonTable.getTableName, "")) + results ++= Seq(("CARBON Store Path ", CarbonProperties.getStorePath, "")) val carbonTable = relation.carbonTable // Carbon table support table comment val tableComment = carbonTable.getTableInfo.getFactTable.getTableProperties.asScala .getOrElse(CarbonCommonConstants.TABLE_COMMENT, "") - results ++= Seq(("Comment: ", tableComment, "")) - results ++= Seq(("Table Block Size : ", carbonTable.getBlockSizeInMB + " MB", "")) + results ++= Seq(("Comment", tableComment, "")) + results ++= Seq(("Table Block Size ", carbonTable.getBlockSizeInMB + " MB", "")) val dataIndexSize = CarbonUtil.calculateDataIndexSize(carbonTable) if (!dataIndexSize.isEmpty) { - results ++= Seq((CarbonCommonConstants.TABLE_DATA_SIZE + ":", + results ++= Seq((CarbonCommonConstants.TABLE_DATA_SIZE, dataIndexSize.get(CarbonCommonConstants.CARBON_TOTAL_DATA_SIZE).toString, "")) - results ++= Seq((CarbonCommonConstants.TABLE_INDEX_SIZE + ":", + results ++= Seq((CarbonCommonConstants.TABLE_INDEX_SIZE, dataIndexSize.get(CarbonCommonConstants.CARBON_TOTAL_INDEX_SIZE).toString, "")) - results ++= Seq((CarbonCommonConstants.LAST_UPDATE_TIME + ":", + results ++= Seq((CarbonCommonConstants.LAST_UPDATE_TIME, dataIndexSize.get(CarbonCommonConstants.LAST_UPDATE_TIME).toString, "")) } results ++= Seq(("SORT_SCOPE", carbonTable.getTableInfo.getFactTable .getTableProperties.asScala.getOrElse("sort_scope", CarbonCommonConstants .LOAD_SORT_SCOPE_DEFAULT), CarbonCommonConstants.LOAD_SORT_SCOPE_DEFAULT)) + val isStreaming = carbonTable.getTableInfo.getFactTable.getTableProperties.asScala + .getOrElse("streaming", "false") + results ++= Seq(("Streaming", isStreaming, "")) results ++= Seq(("", "", ""), ("##Detailed Column property", "", "")) if (colPropStr.length() > 0) { results ++= Seq((colPropStr, "", "")) @@ -135,7 +138,7 @@ private[sql] case class CarbonDescribeFormattedCommand( results ++= getColumnGroups(dimension.asScala.toList) if (carbonTable.getPartitionInfo(carbonTable.getTableName) != null) { results ++= - Seq(("Partition Columns: ", carbonTable.getPartitionInfo(carbonTable.getTableName) + Seq(("Partition Columns", carbonTable.getPartitionInfo(carbonTable.getTableName) .getColumnSchemaList.asScala.map(_.getColumnName).mkString(","), "")) } results.map { http://git-wip-us.apache.org/repos/asf/carbondata/blob/4eb37240/integration/spark2/src/test/scala/org/apache/spark/carbondata/TestStreamingTableOperation.scala ---------------------------------------------------------------------- diff --git a/integration/spark2/src/test/scala/org/apache/spark/carbondata/TestStreamingTableOperation.scala b/integration/spark2/src/test/scala/org/apache/spark/carbondata/TestStreamingTableOperation.scala index 75dcbdf..ad439f2 100644 --- a/integration/spark2/src/test/scala/org/apache/spark/carbondata/TestStreamingTableOperation.scala +++ b/integration/spark2/src/test/scala/org/apache/spark/carbondata/TestStreamingTableOperation.scala @@ -730,6 +730,19 @@ class TestStreamingTableOperation extends QueryTest with BeforeAndAfterAll { ).getMessage.contains("Streaming table does not support creating datamap")) } + test("check streaming property of table") { + checkExistence(sql("DESC FORMATTED batch_table"), true, "Streaming") + val result = + sql("DESC FORMATTED batch_table").collect().filter(_.getString(0).trim.equals("Streaming")) + assertResult(1)(result.length) + assertResult("false")(result(0).getString(1).trim) + + checkExistence(sql("DESC FORMATTED stream_table_file"), true, "Streaming") + val resultStreaming = sql("DESC FORMATTED stream_table_file").collect() + .filter(_.getString(0).trim.equals("Streaming")) + assertResult(1)(resultStreaming.length) + assertResult("true")(resultStreaming(0).getString(1).trim) + } def createWriteSocketThread( serverSocket: ServerSocket, writeNums: Int,
