From 889ab36dff45b84620e178deee060cc71f3d710c Mon Sep 17 00:00:00 2001 From: Sam Firke Date: Wed, 11 Sep 2024 20:17:48 -0400 Subject: [PATCH] fix(uploads): respect db engine spec's supports_multivalues_insert value for file uploads & enable multi-insert for MSSQL (#30222) Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com> (cherry picked from commit f8a77537a77f701496e9b0fe3fe5532d028fb344) --- superset/db_engine_specs/base.py | 7 +++++-- superset/db_engine_specs/mssql.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py index a6b1a6b4b395f..aa30847565d44 100644 --- a/superset/db_engine_specs/base.py +++ b/superset/db_engine_specs/base.py @@ -347,6 +347,7 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods # Does database support join-free timeslot grouping time_groupby_inline = False limit_method = LimitMethod.FORCE_LIMIT + supports_multivalues_insert = False allows_joins = True allows_subqueries = True allows_alias_in_select = True @@ -1283,9 +1284,11 @@ def df_to_sql( catalog=table.catalog, schema=table.schema, ) as engine: - if engine.dialect.supports_multivalues_insert: + if ( + engine.dialect.supports_multivalues_insert + or cls.supports_multivalues_insert + ): to_sql_kwargs["method"] = "multi" - df.to_sql(con=engine, **to_sql_kwargs) @classmethod diff --git a/superset/db_engine_specs/mssql.py b/superset/db_engine_specs/mssql.py index d5cc86c859a7b..464f6cf2b9c8d 100644 --- a/superset/db_engine_specs/mssql.py +++ b/superset/db_engine_specs/mssql.py @@ -53,6 +53,7 @@ class MssqlEngineSpec(BaseEngineSpec): max_column_name_length = 128 allows_cte_in_subquery = False allow_limit_clause = False + supports_multivalues_insert = True _time_grain_expressions = { None: "{col}",