You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/02/17 00:26:44 UTC

[GitHub] [superset] john-bodley commented on a change in pull request #18758: fix: CSV upload with overprescribed table/schema

john-bodley commented on a change in pull request #18758:
URL: https://github.com/apache/superset/pull/18758#discussion_r808471325



##########
File path: superset/views/database/views.py
##########
@@ -130,29 +130,34 @@ def form_get(self, form: CsvToDatabaseForm) -> None:
 
     def form_post(self, form: CsvToDatabaseForm) -> Response:
         database = form.con.data
-        csv_table = Table(table=form.name.data, schema=form.schema.data)
 
-        if not schema_allows_file_upload(database, csv_table.schema):
+        if not schema_allows_file_upload(database, form.schema.data):
             message = _(
-                'Database "%(database_name)s" schema "%(schema_name)s" '
+                'Database "%(database)s" schema "%(schema)s" '
                 "is not allowed for csv uploads. Please contact your Superset Admin.",
-                database_name=database.database_name,
-                schema_name=csv_table.schema,
+                database=database.database_name,
+                schema=form.schema.data,
             )
             flash(message, "danger")
             return redirect("/csvtodatabaseview/form")
 
-        if "." in csv_table.table and csv_table.schema:
+        if "." in form.name.data and form.schema.data:
             message = _(
                 "You cannot specify a namespace both in the name of the table: "
-                '"%(csv_table.table)s" and in the schema field: '
-                '"%(csv_table.schema)s". Please remove one',
-                table=csv_table.table,
-                schema=csv_table.schema,
+                '"%(name)s" and in the schema field: '
+                '"%(schema)s". Please remove one',
+                name=form.name.data,
+                schema=form.schema.data,
             )
             flash(message, "danger")
             return redirect("/csvtodatabaseview/form")
 
+        if "." in form.name.data:
+            table, schema = form.name.data.split(".")

Review comment:
       This logic did not exist previously.

##########
File path: superset/views/database/views.py
##########
@@ -130,29 +130,34 @@ def form_get(self, form: CsvToDatabaseForm) -> None:
 
     def form_post(self, form: CsvToDatabaseForm) -> Response:
         database = form.con.data
-        csv_table = Table(table=form.name.data, schema=form.schema.data)
 
-        if not schema_allows_file_upload(database, csv_table.schema):
+        if not schema_allows_file_upload(database, form.schema.data):
             message = _(
-                'Database "%(database_name)s" schema "%(schema_name)s" '
+                'Database "%(database)s" schema "%(schema)s" '
                 "is not allowed for csv uploads. Please contact your Superset Admin.",
-                database_name=database.database_name,
-                schema_name=csv_table.schema,
+                database=database.database_name,
+                schema=form.schema.data,
             )
             flash(message, "danger")
             return redirect("/csvtodatabaseview/form")
 
-        if "." in csv_table.table and csv_table.schema:
+        if "." in form.name.data and form.schema.data:
             message = _(
                 "You cannot specify a namespace both in the name of the table: "
-                '"%(csv_table.table)s" and in the schema field: '

Review comment:
       This was the initial error. The `csv_table.table` and `csv_table.schema` variables are not inputs to the function.




-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org