villebro commented on a change in pull request #9002: [database] new, API table 
metadata
URL: 
https://github.com/apache/incubator-superset/pull/9002#discussion_r370837666
 
 

 ##########
 File path: superset/views/database/api.py
 ##########
 @@ -50,3 +137,144 @@ class DatabaseRestApi(DatabaseMixin, 
BaseSupersetModelRestApi):
     # Removes the local limit for the page size
     max_page_size = -1
     validators_columns = {"sqlalchemy_uri": sqlalchemy_uri_validator}
+
+    @expose(
+        "/<int:pk>/table/<string:table_name>/<string:schema_name>/", 
methods=["GET"]
+    )
+    @protect()
+    @safe
+    @event_logger.log_this
+    def table_metadata(
+        self, pk: int, table_name: str, schema_name: str
+    ):  # pylint: disable=invalid-name
+        """ Table schema info
+        ---
+        get:
+          parameters:
+          - in: path
+            schema:
+              type: integer
+            name: pk
+            description: The database id
+          - in: path
+            schema:
+              type: string
+            name: table_name
+            description: Table name
+          - in: path
+            schema:
+              type: string
+            name: schema
+            description: Table schema
+          responses:
+            200:
+              description: Table schema info
+              content:
+                text/plain:
+                  schema:
+                    type: object
+                    properties:
+                      columns:
+                        type: array
+                        description: Table columns info
+                        items:
+                          type: object
+                          properties:
+                            keys:
+                              type: array
+                              items:
+                                type: string
+                            longType:
+                              type: string
+                            name:
+                              type: string
+                            type:
+                              type: string
+                      foreignKeys:
+                        type: array
+                        description: Table list of foreign keys
+                        items:
+                          type: object
+                          properties:
+                            column_names:
+                              type: array
+                              items:
+                                type: string
+                            name:
+                              type: string
+                            options:
+                              type: object
+                            referred_columns:
+                              type: array
+                              items:
+                                type: string
+                            referred_schema:
+                              type: string
+                            referred_table:
+                              type: string
+                            type:
+                              type: string
+                      indexes:
+                        type: array
+                        description: Table list of indexes
+                        items:
+                          type: object
+                          properties:
+                            column_names:
+                              type: array
+                              items:
+                                type: string
+                            name:
+                              type: string
+                            options:
+                              type: object
+                            referred_columns:
+                              type: array
+                              items:
+                                type: string
+                            referred_schema:
+                              type: string
+                            referred_table:
+                              type: string
+                            type:
+                              type: string
+                      primaryKey:
+                        type: object
+                        properties:
+                          column_names:
+                            type: array
+                            items:
+                              type: string
+                          name:
+                            type: string
+                          type:
+                            type: string
+            400:
+              $ref: '#/components/responses/400'
+            401:
+              $ref: '#/components/responses/401'
+            404:
+              $ref: '#/components/responses/404'
+            422:
+              $ref: '#/components/responses/422'
+            500:
+              $ref: '#/components/responses/500'
+        """
+        table_name_parsed: Optional[str] = parse_js_uri_path_item(table_name)
+        schema_parsed: Optional[str] = parse_js_uri_path_item(
+            schema_name, eval_undefined=True
+        )
 
 Review comment:
   I think it's already implied i.e.not needed, so would personally remove it 
unless it makes the code more understandable.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to