diff --git a/src/query/storages/fuse/src/table_functions/clustering_information.rs b/src/query/storages/fuse/src/table_functions/clustering_information.rs index 879c7964401e..a624d81ffabe 100644 --- a/src/query/storages/fuse/src/table_functions/clustering_information.rs +++ b/src/query/storages/fuse/src/table_functions/clustering_information.rs @@ -296,7 +296,14 @@ impl<'a> ClusteringInformation<'a> { let (keys, values): (Vec<_>, Vec<_>) = points_map.into_iter().unzip(); let cluster_key_types = exprs .into_iter() - .map(|v| v.data_type().clone()) + .map(|v| { + let data_type = v.data_type(); + if matches!(*data_type, DataType::String) { + data_type.wrap_nullable() + } else { + data_type.clone() + } + }) .collect::>(); let indices = compare_scalars(keys, &cluster_key_types)?; for idx in indices.into_iter() { diff --git a/tests/sqllogictests/suites/base/09_fuse_engine/09_0014_func_clustering_information_function.test b/tests/sqllogictests/suites/base/09_fuse_engine/09_0014_func_clustering_information_function.test index cbf38e6f59b6..49f9ad3d1e4c 100644 --- a/tests/sqllogictests/suites/base/09_fuse_engine/09_0014_func_clustering_information_function.test +++ b/tests/sqllogictests/suites/base/09_fuse_engine/09_0014_func_clustering_information_function.test @@ -86,4 +86,27 @@ select * exclude(timestamp) from clustering_information('default','t09_0014_1', (SUBSTRING(c FROM 2 FOR 2)) linear 2 0 1.0 2.0 {"00002":2} statement ok -drop table t09_0014_1 +drop table t09_0014_1 all + +##issue https://github.com/databendlabs/databend/issues/16763 +statement ok +create table t09_0014_2(c varchar not null) cluster by(substring(c FROM 1 FOR 4)) + +statement ok +insert into t09_0014_2 values('abcde'),('bcdef') + +statement ok +insert into t09_0014_2 values('bcdff'),('cdefg') + +query TTIIFFT +select * exclude(timestamp) from clustering_information('default','t09_0014_2') +---- +(SUBSTRING(c FROM 1 FOR 4)) linear 2 0 0.0 1.0 {"00001":2} + +query TTIIFFT +select * exclude(timestamp) from clustering_information('default','t09_0014_2', 'substr(c,2,4)') +---- +(SUBSTRING(c FROM 2 FOR 4)) linear 2 0 1.0 2.0 {"00002":2} + +statement ok +drop table t09_0014_2 all diff --git a/tests/suites/1_stateful/09_http_handler/09_0007_token.py b/tests/suites/1_stateful/09_http_handler/09_0007_token.py index 25bb875d3cb4..8a8bcfb4a8e4 100755 --- a/tests/suites/1_stateful/09_http_handler/09_0007_token.py +++ b/tests/suites/1_stateful/09_http_handler/09_0007_token.py @@ -133,10 +133,10 @@ def fake_expired_token(ty): "sid": "", } return ( - "bend-v1-" - + ty - + "-" - + base64.b64encode(json.dumps(expired_claim).encode("utf-8")).decode("utf-8") + "bend-v1-" + + ty + + "-" + + base64.b64encode(json.dumps(expired_claim).encode("utf-8")).decode("utf-8") ) @@ -207,6 +207,7 @@ def main(): if __name__ == "__main__": import logging + try: main() except Exception as e: diff --git a/tests/suites/1_stateful/09_http_handler/09_0009_cookie.py b/tests/suites/1_stateful/09_http_handler/09_0009_cookie.py index 1a424f450e0a..910f0c1cbe2b 100755 --- a/tests/suites/1_stateful/09_http_handler/09_0009_cookie.py +++ b/tests/suites/1_stateful/09_http_handler/09_0009_cookie.py @@ -8,13 +8,14 @@ auth = ("root", "") logging.basicConfig(level=logging.ERROR, format="%(asctime)s %(levelname)s %(message)s") + class GlobalCookieJar(RequestsCookieJar): def __init__(self): super().__init__() def set_cookie(self, cookie: Cookie, *args, **kwargs): - cookie.domain = '' - cookie.path = '/' + cookie.domain = "" + cookie.path = "/" super().set_cookie(cookie, *args, **kwargs) def get_dict(self, domain=None, path=None): @@ -22,11 +23,11 @@ def get_dict(self, domain=None, path=None): return {cookie.name: cookie.value for cookie in self} -def do_query(session_client, query, session_state=None ): +def do_query(session_client, query, session_state=None): url = f"http://localhost:8000/v1/query" query_payload = { "sql": query, - "pagination": {"wait_time_secs": 100, 'max_rows_per_page': 2}, + "pagination": {"wait_time_secs": 100, "max_rows_per_page": 2}, } if session_state: query_payload["session"] = session_state @@ -47,10 +48,10 @@ def test_simple(): assert resp.status_code == 200, resp.text assert resp.json()["data"] == [["1"]], resp.text sid = client.cookies.get("session_id") - #print(sid) + # print(sid) last_access_time1 = int(client.cookies.get("last_access_time")) - #print(last_access_time1) + # print(last_access_time1) assert time.time() - 10 < last_access_time1 < time.time() time.sleep(1.5) @@ -83,7 +84,7 @@ def test_temp_table(): resp = do_query(client, "select * from t1", session_state) assert resp.status_code == 200, resp.text - assert resp.json()['data'] == [["3"], ["4"]] + assert resp.json()["data"] == [["3"], ["4"]] session_state = resp.json()["session"] assert session_state["need_sticky"], resp.text assert session_state["need_keep_alive"] @@ -99,6 +100,7 @@ def main(): test_simple() test_temp_table() + if __name__ == "__main__": try: main()