Skip to content

Commit

Permalink
fix: bump Helm chart release version (#18751) (#18758)
Browse files Browse the repository at this point in the history
Co-authored-by: wiktor2200 <wiktor2200@users.noreply.github.com>
  • Loading branch information
john-bodley and wiktor2200 committed Feb 25, 2022
1 parent 79633ce commit 0994217
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 37 deletions.
17 changes: 13 additions & 4 deletions superset/views/database/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
StringField,
)
from wtforms.ext.sqlalchemy.fields import QuerySelectField
from wtforms.validators import DataRequired, Length, NumberRange, Optional
from wtforms.validators import DataRequired, Length, NumberRange, Optional, Regexp

from superset import app, db, security_manager
from superset.forms import (
Expand Down Expand Up @@ -94,7 +94,10 @@ class CsvToDatabaseForm(UploadToDatabaseForm):
name = StringField(
_("Table Name"),
description=_("Name of table to be created from csv data."),
validators=[DataRequired()],
validators=[
DataRequired(),
Regexp(r"^[^\.]+$", message=_("Table name cannot contain a schema")),
],
widget=BS3TextFieldWidget(),
)
csv_file = FileField(
Expand Down Expand Up @@ -245,7 +248,10 @@ class ExcelToDatabaseForm(UploadToDatabaseForm):
name = StringField(
_("Table Name"),
description=_("Name of table to be created from excel data."),
validators=[DataRequired()],
validators=[
DataRequired(),
Regexp(r"^[^\.]+$", message=_("Table name cannot contain a schema")),
],
widget=BS3TextFieldWidget(),
)
excel_file = FileField(
Expand Down Expand Up @@ -378,7 +384,10 @@ class ColumnarToDatabaseForm(UploadToDatabaseForm):
name = StringField(
_("Table Name"),
description=_("Name of table to be created from columnar data."),
validators=[DataRequired()],
validators=[
DataRequired(),
Regexp(r"^[^\.]+$", message=_("Table name cannot contain a schema")),
],
widget=BS3TextFieldWidget(),
)
columnar_file = MultipleFileField(
Expand Down
33 changes: 0 additions & 33 deletions superset/views/database/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,6 @@ def form_post(self, form: CsvToDatabaseForm) -> Response:
flash(message, "danger")
return redirect("/csvtodatabaseview/form")

if "." in csv_table.table and csv_table.schema:
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,
)
flash(message, "danger")
return redirect("/csvtodatabaseview/form")

try:
df = pd.concat(
pd.read_csv(
Expand Down Expand Up @@ -289,17 +278,6 @@ def form_post(self, form: ExcelToDatabaseForm) -> Response:
flash(message, "danger")
return redirect("/exceltodatabaseview/form")

if "." in excel_table.table and excel_table.schema:
message = _(
"You cannot specify a namespace both in the name of the table: "
'"%(excel_table.table)s" and in the schema field: '
'"%(excel_table.schema)s". Please remove one',
table=excel_table.table,
schema=excel_table.schema,
)
flash(message, "danger")
return redirect("/exceltodatabaseview/form")

uploaded_tmp_file_path = tempfile.NamedTemporaryFile( # pylint: disable=consider-using-with
dir=app.config["UPLOAD_FOLDER"],
suffix=os.path.splitext(form.excel_file.data.filename)[1].lower(),
Expand Down Expand Up @@ -459,17 +437,6 @@ def form_post( # pylint: disable=too-many-locals
flash(message, "danger")
return redirect("/columnartodatabaseview/form")

if "." in columnar_table.table and columnar_table.schema:
message = _(
"You cannot specify a namespace both in the name of the table: "
'"%(columnar_table.table)s" and in the schema field: '
'"%(columnar_table.schema)s". Please remove one',
table=columnar_table.table,
schema=columnar_table.schema,
)
flash(message, "danger")
return redirect("/columnartodatabaseview/form")

try:
chunks = [read(file, **kwargs) for file in files]
df = pd.concat(chunks)
Expand Down
4 changes: 4 additions & 0 deletions tests/integration_tests/csv_upload_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ def test_import_csv_enforced_schema(mock_event_logger):

full_table_name = f"admin_database.{CSV_UPLOAD_TABLE_W_SCHEMA}"

# Invalid table name
resp = upload_csv(CSV_FILENAME1, full_table_name)
assert "Table name cannot contain a schema" in resp

# no schema specified, fail upload
resp = upload_csv(CSV_FILENAME1, CSV_UPLOAD_TABLE_W_SCHEMA, extra={"schema": None})
assert (
Expand Down

0 comments on commit 0994217

Please sign in to comment.