godfreyhe commented on a change in pull request #11892:
URL: https://github.com/apache/flink/pull/11892#discussion_r415473253



##########
File path: 
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/internal/TableEnvImpl.scala
##########
@@ -721,6 +721,15 @@ abstract class TableEnvImpl(
             dropViewOperation.isIfExists)
         }
         TableResultImpl.TABLE_RESULT_OK
+      case descOperation: DescribeTableOperation =>
+        val result = catalogManager.getTable(descOperation.getSqlIdentifier)
+        if (result.isPresent) {
+          buildShowResult(Array(result.get().getTable.getSchema.toString))

Review comment:
       I find the print (through `TableResult#print`) result of `describe xx` 
looks a little strange:
   ```
   +--------------------------------+
   |                         result |
   +--------------------------------+
   |  root
    |-- a: INT
    |-- b: S... |
   +--------------------------------+
   1 row in set
   ```
   
   Users have to parse the unstructured result if he/she want to use the result 
to do sth through  TableResult#collect method.
   
   How about we return a structured tableau result, e.g. 
   ```
   +-------------+---------+-------------+
   |     name    |   type  |   comment   |
   +-------------+---------+-------------+
   |      a      |   INT   |             |
   |      b      |  STRING |             |
   +-------------+---------+-------------+
    2 rows in set
   ```
   This is different from the describe result in SQL client.
   
   Anther thing we should consider is how to print `watermarkSpecs` and compute 
column.
   How about we add a column named `expr` to represent `watermarkSpecs` and 
compute column.
   ```
         +-------------+-------------+-------------+-------------+
         |     name    |     type    |   comment   |   expr      |
         +-------------+-------------+-------------+-------------+
         |      a      |    INT      |             |  (NULL)     |
         |      b      |    INT      |             |   a + 1     |
         |      c      |TIMESTAMP(3) |             |  (NULL)     |
         | WATERMARK   |  (NULL)     |             | c AS now()  |
         +-------------+-------------+-------------+-------------+
   ```
   

##########
File path: 
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/internal/TableEnvImpl.scala
##########
@@ -721,6 +721,15 @@ abstract class TableEnvImpl(
             dropViewOperation.isIfExists)
         }
         TableResultImpl.TABLE_RESULT_OK
+      case descOperation: DescribeTableOperation =>
+        val result = catalogManager.getTable(descOperation.getSqlIdentifier)
+        if (result.isPresent) {
+          buildShowResult(Array(result.get().getTable.getSchema.toString))

Review comment:
       cc @twalthr 




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to