mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
feat: add option for hash algorithms (#35621)
Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8d7c83419c
commit
bb22eb1ca8
@@ -19,7 +19,7 @@ import pytest
|
||||
from superset.utils.core import form_data_to_adhoc, simple_filter_to_adhoc
|
||||
|
||||
|
||||
def test_simple_filter_to_adhoc_generates_deterministic_values():
|
||||
def test_simple_filter_to_adhoc_generates_deterministic_values(app_context):
|
||||
input_1 = {
|
||||
"op": "IS NOT NULL",
|
||||
"col": "LATITUDE",
|
||||
@@ -30,13 +30,16 @@ def test_simple_filter_to_adhoc_generates_deterministic_values():
|
||||
|
||||
# The result is the same when given the same input
|
||||
assert simple_filter_to_adhoc(input_1) == simple_filter_to_adhoc(input_1)
|
||||
# SHA-256 filterOptionName hash with default HASH_ALGORITHM
|
||||
assert simple_filter_to_adhoc(input_1) == {
|
||||
"clause": "WHERE",
|
||||
"expressionType": "SIMPLE",
|
||||
"comparator": "",
|
||||
"operator": "IS NOT NULL",
|
||||
"subject": "LATITUDE",
|
||||
"filterOptionName": "6ac89d498115da22396f80a765cffc70",
|
||||
"filterOptionName": (
|
||||
"84ffe4dba1764c30568e19d4dbbf64717fbc514fad1a8a995debfc72b344aa76"
|
||||
),
|
||||
}
|
||||
|
||||
# The result is different when given different input
|
||||
@@ -47,22 +50,27 @@ def test_simple_filter_to_adhoc_generates_deterministic_values():
|
||||
"comparator": "",
|
||||
"operator": "IS NOT NULL",
|
||||
"subject": "LONGITUDE",
|
||||
"filterOptionName": "9c984bd3714883ca859948354ce26ab9",
|
||||
"filterOptionName": (
|
||||
"c5a54054b987350b5594ee73772fbe71e9651a475bfcb7ae740e0799f12c8ff7"
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def test_form_data_to_adhoc_generates_deterministic_values():
|
||||
def test_form_data_to_adhoc_generates_deterministic_values(app_context):
|
||||
form_data = {"where": "1 = 1", "having": "count(*) > 1"}
|
||||
|
||||
# The result is the same when given the same input
|
||||
assert form_data_to_adhoc(form_data, "where") == form_data_to_adhoc(
|
||||
form_data, "where"
|
||||
)
|
||||
# SHA-256 filterOptionName hash with default HASH_ALGORITHM
|
||||
assert form_data_to_adhoc(form_data, "where") == {
|
||||
"clause": "WHERE",
|
||||
"expressionType": "SQL",
|
||||
"sqlExpression": "1 = 1",
|
||||
"filterOptionName": "99fe79985afbddea4492626dc6a87b74",
|
||||
"filterOptionName": (
|
||||
"11f7ef40818a0d614cc9a989d5d75ee969b5b3724e973dbf0194e3a339aa0544"
|
||||
),
|
||||
}
|
||||
|
||||
# The result is different when given different input
|
||||
@@ -73,11 +81,13 @@ def test_form_data_to_adhoc_generates_deterministic_values():
|
||||
"clause": "HAVING",
|
||||
"expressionType": "SQL",
|
||||
"sqlExpression": "count(*) > 1",
|
||||
"filterOptionName": "1da11f6b709c3190daeabb84f77fc8c2",
|
||||
"filterOptionName": (
|
||||
"8768cb92fa8a8629695dfe3a4010daefc5d7586934d1aa775f22fb03b46b5dcb"
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def test_form_data_to_adhoc_incorrect_clause_type():
|
||||
def test_form_data_to_adhoc_incorrect_clause_type(app_context):
|
||||
form_data = {"where": "1 = 1", "having": "count(*) > 1"}
|
||||
|
||||
with pytest.raises(ValueError): # noqa: PT011
|
||||
|
||||
Reference in New Issue
Block a user