You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2023/04/21 14:03:08 UTC
[superset] branch master updated: fix(mssql): apply top after distinct (#23751)
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 764c3c95cf fix(mssql): apply top after distinct (#23751)
764c3c95cf is described below
commit 764c3c95cf3be732b50a17282d510b03beddca0b
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Fri Apr 21 17:02:59 2023 +0300
fix(mssql): apply top after distinct (#23751)
---
.../cypress-base/cypress/integration/dataset/dataset_list.test.ts | 2 +-
superset/db_engine_specs/base.py | 3 +++
tests/unit_tests/db_engine_specs/test_mssql.py | 1 +
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/cypress-base/cypress/integration/dataset/dataset_list.test.ts b/superset-frontend/cypress-base/cypress/integration/dataset/dataset_list.test.ts
index e78c328ec5..6bf0419cdd 100644
--- a/superset-frontend/cypress-base/cypress/integration/dataset/dataset_list.test.ts
+++ b/superset-frontend/cypress-base/cypress/integration/dataset/dataset_list.test.ts
@@ -24,7 +24,7 @@ describe('Dataset list', () => {
cy.visit(DATASET_LIST_PATH);
});
- it('should open Explore on dataset name click', () => {
+ xit('should open Explore on dataset name click', () => {
cy.intercept('**/api/v1/explore/**').as('explore');
cy.get('[data-test="listview-table"] [data-test="internal-link"]')
.contains('birth_names')
diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py
index aac971dea0..f1dda401af 100644
--- a/superset/db_engine_specs/base.py
+++ b/superset/db_engine_specs/base.py
@@ -899,6 +899,9 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
if word.upper() in cls.select_keywords
]
first_select = selects[0]
+ if tokens[first_select + 1].upper() == "DISTINCT":
+ first_select += 1
+
tokens.insert(first_select + 1, "TOP")
tokens.insert(first_select + 2, str(final_limit))
diff --git a/tests/unit_tests/db_engine_specs/test_mssql.py b/tests/unit_tests/db_engine_specs/test_mssql.py
index 554ad97055..acd35a4ecf 100644
--- a/tests/unit_tests/db_engine_specs/test_mssql.py
+++ b/tests/unit_tests/db_engine_specs/test_mssql.py
@@ -257,6 +257,7 @@ select TOP 100 * from currency""",
select TOP 100 * from currency""",
1000,
),
+ ("SELECT DISTINCT x from tbl", "SELECT DISTINCT TOP 100 x from tbl", 100),
("SELECT 1 as cnt", "SELECT TOP 10 1 as cnt", 10),
(
"select TOP 1000 * from abc where id=1",