Skip to content

Commit 4f61c69

Browse files
committed
style: fix clang-format and ruff lint violations
Apply clang-format line-break and spacing fixes in C++ sources, sort Python imports per isort rules, and reformat long lines in test file to satisfy ruff format.
1 parent 64aaa0d commit 4f61c69

3 files changed

Lines changed: 33 additions & 17 deletions

File tree

src/pgduckdb_planner.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ CreatePlan(Query *query, bool throw_error) {
7373

7474
elog(DEBUG2, "(PGDuckDB/CreatePlan) DuckDB Prepare returned %zu result column(s)", prepared_result_types.size());
7575
for (size_t j = 0; j < prepared_result_types.size(); j++) {
76-
elog(DEBUG2, "(PGDuckDB/CreatePlan) col[%zu] = %s name=%s", j,
77-
prepared_result_types[j].ToString().c_str(),
76+
elog(DEBUG2, "(PGDuckDB/CreatePlan) col[%zu] = %s name=%s", j, prepared_result_types[j].ToString().c_str(),
7877
prepared_query->GetNames()[j].c_str());
7978
}
8079

src/pgduckdb_types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ ConvertDuckToPostgresValue(TupleTableSlot *slot, duckdb::Value &value, idx_t col
11221122
case TEXTOID:
11231123
case JSONOID:
11241124
case UNKNOWNOID:
1125-
case 0: /* InvalidOid - for UNKNOWN columns where tuple descriptor has no type */
1125+
case 0: /* InvalidOid - for UNKNOWN columns where tuple descriptor has no type */
11261126
case VARCHAROID: {
11271127
slot->tts_values[col] = ConvertToStringDatum(value);
11281128
break;

test/pycheck/prepared_test.py

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
2-
from decimal import Decimal
32
import uuid
3+
from decimal import Decimal
44

55
import duckdb
66
import psycopg.errors
@@ -47,7 +47,9 @@ def test_prepared(cur: Cursor):
4747

4848
def test_prepared_select_list_parameters(cur: Cursor):
4949
cur.sql("CREATE TEMP TABLE t_select_param (id int, name text) USING duckdb")
50-
cur.sql("INSERT INTO t_select_param VALUES (1, 'alice'), (2, 'bob'), (42, 'charlie')")
50+
cur.sql(
51+
"INSERT INTO t_select_param VALUES (1, 'alice'), (2, 'bob'), (42, 'charlie')"
52+
)
5153

5254
expected_rows = [
5355
("my_label", 1, "alice"),
@@ -61,8 +63,12 @@ def test_prepared_select_list_parameters(cur: Cursor):
6163
q_select = "SELECT %s AS label, id, name FROM t_select_param ORDER BY id"
6264
assert cur.sql(q_select, ("my_label",), prepare=True) == expected_rows
6365

64-
q_select_where = "SELECT %s AS label, id, name FROM t_select_param WHERE id = %s"
65-
assert cur.sql(q_select_where, ("my_label", 42), prepare=True) == [("my_label", 42, "charlie")]
66+
q_select_where = (
67+
"SELECT %s AS label, id, name FROM t_select_param WHERE id = %s"
68+
)
69+
assert cur.sql(q_select_where, ("my_label", 42), prepare=True) == [
70+
("my_label", 42, "charlie")
71+
]
6672

6773

6874
def _create_typed_bind_parquet(tmp_path) -> str:
@@ -103,7 +109,9 @@ def test_prepared_parquet_untyped_in_param(cur: Cursor, tmp_path):
103109
def test_prepared_parquet_casted_param_controls(cur: Cursor, tmp_path):
104110
parquet_path = _create_typed_bind_parquet(tmp_path)
105111
q_between = "SELECT count(*) FROM read_parquet(%s) t WHERE t['bc_date'] BETWEEN %s::integer AND %s::integer"
106-
q_in = "SELECT count(*) FROM read_parquet(%s) t WHERE t['data_stream'] IN (%s::text)"
112+
q_in = (
113+
"SELECT count(*) FROM read_parquet(%s) t WHERE t['data_stream'] IN (%s::text)"
114+
)
107115
cur.sql("SET duckdb.force_execution = true")
108116

109117
for mode in ("force_custom_plan", "force_generic_plan"):
@@ -123,7 +131,9 @@ def test_prepared_parquet_native_prepare_execute_between(cur: Cursor, tmp_path):
123131

124132
for mode in ("force_custom_plan", "force_generic_plan"):
125133
cur.sql(f"SET plan_cache_mode = '{mode}'")
126-
cur.sql(f"PREPARE b1_between AS SELECT count(*) FROM read_parquet('{escaped_path}') t WHERE t['bc_date'] BETWEEN $1 AND $2")
134+
cur.sql(
135+
f"PREPARE b1_between AS SELECT count(*) FROM read_parquet('{escaped_path}') t WHERE t['bc_date'] BETWEEN $1 AND $2"
136+
)
127137
assert cur.sql("EXECUTE b1_between(20240901, 20240902)") == 2
128138
cur.sql("DEALLOCATE b1_between")
129139

@@ -139,7 +149,9 @@ def test_prepared_parquet_native_prepare_execute_in(cur: Cursor, tmp_path):
139149

140150
for mode in ("force_custom_plan", "force_generic_plan"):
141151
cur.sql(f"SET plan_cache_mode = '{mode}'")
142-
cur.sql(f"PREPARE b3_in AS SELECT count(*) FROM read_parquet('{escaped_path}') t WHERE t['data_stream'] IN ($1)")
152+
cur.sql(
153+
f"PREPARE b3_in AS SELECT count(*) FROM read_parquet('{escaped_path}') t WHERE t['data_stream'] IN ($1)"
154+
)
143155
assert cur.sql("EXECUTE b3_in('lv')") == 1
144156
cur.sql("DEALLOCATE b3_in")
145157

@@ -277,13 +289,18 @@ def test_prepared_array_parameters(cur: Cursor):
277289
assert cur.sql(q_num, ([Decimal("1.1"), Decimal("2.2")],), prepare=True) == 1
278290

279291
cur.sql("SET plan_cache_mode = 'force_generic_plan'")
280-
assert cur.sql(q_num, ([Decimal("1.1"), Decimal("2.2")],)) == 1 # creates generic plan
281-
282-
283-
@pytest.mark.parametrize("type_sql,value", [
284-
("oid", 42),
285-
("name", "myname"),
286-
])
292+
assert (
293+
cur.sql(q_num, ([Decimal("1.1"), Decimal("2.2")],)) == 1
294+
) # creates generic plan
295+
296+
297+
@pytest.mark.parametrize(
298+
"type_sql,value",
299+
[
300+
("oid", 42),
301+
("name", "myname"),
302+
],
303+
)
287304
def test_prepared_unsupported_parameter_type(cur: Cursor, type_sql, value):
288305
cur.sql(f"CREATE TABLE t(x {type_sql}) USING duckdb")
289306
cur.sql("INSERT INTO t VALUES (%s)", (value,))

0 commit comments

Comments
 (0)