Skip to content

Commit 6cbd8e5

Browse files
authored
feat: rename body_format query_result_format. (#730)
1 parent 0707a2d commit 6cbd8e5

8 files changed

Lines changed: 39 additions & 33 deletions

File tree

.github/workflows/bindings.python.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,17 @@ jobs:
174174
working-directory: bindings/python
175175
run: behave tests/asyncio
176176
env:
177-
BODY_FORMAT: ${{ matrix.body }}
177+
QUERY_RESULT_FORMAT: ${{ matrix.body }}
178178
- name: Test Blocking
179179
working-directory: bindings/python
180180
run: behave tests/blocking
181181
env:
182-
BODY_FORMAT: ${{ matrix.body }}
182+
QUERY_RESULT_FORMAT: ${{ matrix.body }}
183183
- name: Test Cursor
184184
working-directory: bindings/python
185185
run: behave tests/cursor
186186
env:
187-
BODY_FORMAT: ${{ matrix.body }}
187+
QUERY_RESULT_FORMAT: ${{ matrix.body }}
188188

189189
compat:
190190
name: Compat Test

bindings/python/tests/asyncio/steps/binding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ async def _(context):
4949
"TEST_DATABEND_DSN",
5050
"databend://root:root@localhost:8000/?sslmode=disable",
5151
)
52-
if os.getenv("BODY_FORMAT") == "arrow":
53-
dsn += "&body_format=arrow"
52+
if os.getenv("QUERY_RESULT_FORMAT") == "arrow":
53+
dsn += "&query_result_format=arrow"
5454
client = databend_driver.AsyncDatabendClient(dsn)
5555
context.conn = await client.get_conn()
5656
context.client = client

bindings/python/tests/blocking/steps/binding.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def _(context):
5050
"TEST_DATABEND_DSN",
5151
"databend://root:root@localhost:8000/?sslmode=disable",
5252
)
53-
if os.getenv("BODY_FORMAT") == "arrow":
54-
dsn += "&body_format=arrow"
53+
if os.getenv("QUERY_RESULT_FORMAT") == "arrow":
54+
dsn += "&query_result_format=arrow"
5555
client = databend_driver.BlockingDatabendClient(dsn)
5656
context.conn = client.get_conn()
5757
context.client = client
@@ -176,8 +176,11 @@ def _(context):
176176
)
177177
exp = datetime(2024, 4, 16, 12, 34, 56, 789000, tzinfo=tz_expected)
178178
exp_bug = datetime(2024, 4, 16, 18, 34, 56, 789000, tzinfo=tz_expected)
179-
if (DB_VERSION >= (1, 2, 840) and not os.getenv("BODY_FORMAT") == "arrow") or (
180-
DB_VERSION >= (1, 2, 844) and os.getenv("BODY_FORMAT") == "arrow"
179+
if (
180+
DB_VERSION >= (1, 2, 840)
181+
and not os.getenv("QUERY_RESULT_FORMAT") == "arrow"
182+
) or (
183+
DB_VERSION >= (1, 2, 844) and os.getenv("QUERY_RESULT_FORMAT") == "arrow"
181184
):
182185
assert row.values()[0] == exp, f"timestamp_tz: {row.values()[0]} {exp}"
183186
else:

bindings/python/tests/cursor/steps/binding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def _(context):
5050
"TEST_DATABEND_DSN",
5151
"databend://root:root@localhost:8000/?sslmode=disable",
5252
)
53-
if os.getenv("BODY_FORMAT") == "arrow":
54-
dsn += "&body_format=arrow"
53+
if os.getenv("QUERY_RESULT_FORMAT") == "arrow":
54+
dsn += "&query_result_format=arrow"
5555
client = databend_driver.BlockingDatabendClient(dsn)
5656
context.client = client
5757
context.cursor = client.cursor()

cli/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ DATABEND_USER=${DATABEND_USER:-root}
2121
DATABEND_PASSWORD=${DATABEND_PASSWORD:-}
2222
DATABEND_HOST=${DATABEND_HOST:-localhost}
2323
DATABEND_PORT=${DATABEND_PORT:-8000}
24-
BODY_FORMAT=${BODY_FORMAT:-json}
24+
QUERY_RESULT_FORMAT=${QUERY_RESULT_FORMAT:-json}
2525

2626
TEST_HANDLER=$1
2727
FILTER=$2
@@ -35,7 +35,7 @@ case $TEST_HANDLER in
3535
;;
3636
"http")
3737
echo "==> Testing REST API handler"
38-
export BENDSQL_DSN="databend://${DATABEND_USER}:${DATABEND_PASSWORD}@${DATABEND_HOST}:${DATABEND_PORT}/?sslmode=disable&presign=on&body_format=${BODY_FORMAT}"
38+
export BENDSQL_DSN="databend://${DATABEND_USER}:${DATABEND_PASSWORD}@${DATABEND_HOST}:${DATABEND_PORT}/?sslmode=disable&presign=on&query_result_format=${QUERY_RESULT_FORMAT}"
3939
;;
4040
*)
4141
echo "Usage: $0 [flight|http]"

core/src/client.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub struct APIClient {
106106
route_hint: RouteHintGenerator,
107107

108108
disable_login: bool,
109-
body_format: String,
109+
query_result_format: String,
110110
disable_session_token: bool,
111111
session_token_info: Option<Arc<Mutex<(SessionTokenInfo, Instant)>>>,
112112

@@ -263,13 +263,13 @@ impl APIClient {
263263
}
264264
}
265265
}
266-
"body_format" => {
266+
"body_format" | "query_result_format" => {
267267
let v = v.to_string().to_lowercase();
268268
match v.as_str() {
269-
"json" | "arrow" => client.body_format = v.to_string(),
269+
"json" | "arrow" => client.query_result_format = v.to_string(),
270270
_ => {
271271
return Err(Error::BadArgument(format!(
272-
"Invalid value for body_format: {v}"
272+
"Invalid value for query_result_format: {v}"
273273
)))
274274
}
275275
}
@@ -508,7 +508,7 @@ impl APIClient {
508508
// headers
509509
let query_id = self.gen_query_id();
510510
let mut headers = self.make_headers(Some(&query_id))?;
511-
if self.capability.arrow_data && self.body_format == "arrow" && !force_json_body {
511+
if self.capability.arrow_data && self.query_result_format == "arrow" && !force_json_body {
512512
debug!("accept arrow data");
513513
headers.insert(ACCEPT, HeaderValue::from_static(CONTENT_TYPE_ARROW_OR_JSON));
514514
}
@@ -604,7 +604,7 @@ impl APIClient {
604604
info!("query page: {next_uri}");
605605
let endpoint = self.endpoint.join(next_uri)?;
606606
let mut headers = self.make_headers(Some(query_id))?;
607-
if self.capability.arrow_data && self.body_format == "arrow" {
607+
if self.capability.arrow_data && self.query_result_format == "arrow" {
608608
headers.insert(ACCEPT, HeaderValue::from_static(CONTENT_TYPE_ARROW_OR_JSON));
609609
}
610610
let mut builder = self.cli.get(endpoint.clone());
@@ -1294,7 +1294,7 @@ impl Default for APIClient {
12941294
last_node_id: Default::default(),
12951295
disable_session_token: true,
12961296
disable_login: false,
1297-
body_format: "json".to_string(),
1297+
query_result_format: "json".to_string(),
12981298
session_token_info: None,
12991299
closed: AtomicBool::new(false),
13001300
last_query_id: Default::default(),

tests/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test-driver: up
2525
test-bendsql: up
2626
cd .. && ./cli/test.sh http
2727
cd .. && ./cli/test.sh flight
28-
BODY_FORMAT=arrow cd .. && ./cli/test.sh http
28+
QUERY_RESULT_FORMAT=arrow cd .. && ./cli/test.sh http
2929

3030
test-bindings-python: up
3131
cd ../bindings/python && behave tests/asyncio

tests/nox/noxfile.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818

1919
def generate_params1():
2020
for db_version in ["1.2.803", "1.2.791"]:
21-
for body_format in ["arrow", "json"]:
21+
for query_result_format in ["arrow", "json"]:
2222
v = tuple(map(int, db_version.split(".")))
23-
if body_format == "arrow" and v < (1, 2, 836):
23+
if query_result_format == "arrow" and v < (1, 2, 836):
2424
continue
25-
yield nox.param(db_version, body_format)
25+
yield nox.param(db_version, query_result_format)
2626

2727

2828
@nox.session
29-
@nox.parametrize(["db_version", "body_format"], generate_params1())
30-
def new_driver_with_old_servers(session, db_version, body_format):
29+
@nox.parametrize(["db_version", "query_result_format"], generate_params1())
30+
def new_driver_with_old_servers(session, db_version, query_result_format):
3131
query_version = f"v{db_version}-nightly"
3232
session.install("behave")
3333
# cd bindings/python
@@ -42,27 +42,30 @@ def new_driver_with_old_servers(session, db_version, body_format):
4242
"DATABEND_QUERY_VERSION": query_version,
4343
"DATABEND_META_VERSION": query_version,
4444
"DB_VERSION": db_version,
45-
"BODY_FORMAT": body_format,
45+
"QUERY_RESULT_FORMAT": query_result_format,
4646
}
4747
session.run("make", "test-bindings-python", env=env)
4848
session.run("make", "down")
4949

5050

5151
def generate_params2():
5252
for driver_version in ["0.28.2", "0.28.1"]:
53-
for body_format in ["arrow", "json"]:
53+
for query_result_format in ["arrow", "json"]:
5454
v = tuple(map(int, driver_version.split(".")))
55-
if body_format == "arrow" and v <= (0, 30, 3):
55+
if query_result_format == "arrow" and v <= (0, 30, 3):
5656
continue
57-
yield nox.param(driver_version, body_format)
57+
yield nox.param(driver_version, query_result_format)
5858

5959

6060
@nox.session
61-
@nox.parametrize(["driver_version", "body_format"], generate_params2())
62-
def new_test_with_old_drivers(session, driver_version, body_format):
61+
@nox.parametrize(["driver_version", "query_result_format"], generate_params2())
62+
def new_test_with_old_drivers(session, driver_version, query_result_format):
6363
session.install("behave")
6464
session.install(f"databend-driver=={driver_version}")
6565
with session.chdir(".."):
66-
env = {"DRIVER_VERSION": driver_version, "BODY_FORMAT": body_format}
66+
env = {
67+
"DRIVER_VERSION": driver_version,
68+
"QUERY_RESULT_FORMAT": query_result_format,
69+
}
6770
session.run("make", "test-bindings-python", env=env)
6871
session.run("make", "down")

0 commit comments

Comments
 (0)