Skip to content

Commit cee5222

Browse files
authored
Add REPL example (#553)
Both as a literal Rust example and for debugging purposes. Demo: ![CleanShot 2025-07-23 at 15 40 14](https://github.com/user-attachments/assets/2ea57fef-26c4-44ff-9e03-7ebdf41b089a) For example, here's how it can be used to reproduce #396 ``` ❯ cargo run --example repl Compiling duckdb v1.3.2 (/Users/mathias/devel/duckdb/duckdb-rs/crates/duckdb) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.48s Running `target/debug/examples/repl` duckdb-rs v1.3.2 🦀 Type '.help' for help. > SELECT (i*10^i)::varchar AS str FROM range(5) tbl(i) +---------+ | str | | Utf8 | +---------+ | 0.0 | | 10.0 | | 200.0 | | 3000.0 | | 40000.0 | +---------+ > SET produce_arrow_string_view = true; > SELECT (i*10^i)::varchar AS str FROM range(5) tbl(i) +---------+ | str | | Utf8 | +---------+ | 0.0 | | 10.0 | | 200.0 | | 3000.0 | | 40000.0 | +---------+ > set arrow_output_version = '1.4' > SELECT (i*10^i)::varchar AS str FROM range(5) tbl(i) +----------+ | str | | Utf8View | +----------+ | 0.0 | | 10.0 | | 200.0 | | 3000.0 | | 40000.0 | +----------+ ``` Debug mode will output more info: ``` > .debug > SELECT (i*10^i)::varchar AS str FROM range(5) tbl(i) +----------+ | str | | Utf8View | +----------+ | 0.0 | | 10.0 | | 200.0 | | 3000.0 | | 40000.0 | +----------+ [crates/duckdb/examples/repl.rs:173:13] &rbs = [ RecordBatch { schema: Schema { fields: [ Field { name: "str", data_type: Utf8View, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {}, }, ], metadata: {}, }, columns: [ StringViewArray [ "0.0", "10.0", "200.0", "3000.0", "40000.0", ], ], row_count: 5, }, ] ```
2 parents 72ae69a + dd81561 commit cee5222

File tree

4 files changed

+400
-135
lines changed

4 files changed

+400
-135
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@
2525
crates/libduckdb-sys/duckdb-sources/*
2626
crates/libduckdb-sys/duckdb/
2727
crates/libduckdb-sys/._duckdb
28+
29+
.duckdb_rs_history

0 commit comments

Comments
 (0)