Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clustering_information panic if string domain is none #16792

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();
let indices = compare_scalars(keys, &cluster_key_types)?;
for idx in indices.into_iter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions tests/suites/1_stateful/09_http_handler/09_0007_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)


Expand Down Expand Up @@ -207,6 +207,7 @@ def main():

if __name__ == "__main__":
import logging

try:
main()
except Exception as e:
Expand Down
16 changes: 9 additions & 7 deletions tests/suites/1_stateful/09_http_handler/09_0009_cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@
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):
# 忽略 domain 和 path 参数,返回所有 Cookie
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
Expand All @@ -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)
Expand Down Expand Up @@ -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"]
Expand All @@ -99,6 +100,7 @@ def main():
test_simple()
test_temp_table()


if __name__ == "__main__":
try:
main()
Expand Down
Loading