Skip to content

Commit

Permalink
upgrade to 0.8.0 (#160)
Browse files Browse the repository at this point in the history
* upgrade to 0.8.0

* try fix windows

* update code

* fix test

* fix build error

* update

* fix path
  • Loading branch information
wangfenjin authored May 20, 2023
1 parent 6795035 commit cfda58b
Show file tree
Hide file tree
Showing 13 changed files with 247 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
name: Download duckdb
with:
repository: "duckdb/duckdb"
tag: "v0.7.1"
tag: "v0.8.0"
fileName: ${{ matrix.duckdb }}
out-file-path: .

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "duckdb"
version = "0.7.1"
version = "0.8.0"
authors = ["wangfenjin <[email protected]>"]
edition = "2021"
description = "Ergonomic wrapper for DuckDB"
Expand Down Expand Up @@ -81,7 +81,7 @@ tempdir = "0.3.7"

[dependencies.libduckdb-sys]
path = "libduckdb-sys"
version = "0.7.1"
version = "0.8.0"

[package.metadata.docs.rs]
features = []
Expand Down
2 changes: 1 addition & 1 deletion libduckdb-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libduckdb-sys"
version = "0.7.1"
version = "0.8.0"
authors = ["wangfenjin <[email protected]>"]
edition = "2021"
build = "build.rs"
Expand Down
3 changes: 1 addition & 2 deletions libduckdb-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ mod build_bundled {
#[cfg(not(feature = "buildtime_bindgen"))]
{
use std::fs;
fs::copy(format!("{}/bindgen_bundled_version.rs", lib_name), out_path)
.expect("Could not copy bindings to output directory");
fs::copy("src/bindgen_bundled_version.rs", out_path).expect("Could not copy bindings to output directory");
}

let manifest_file = std::fs::File::open(format!("{}/manifest.json", lib_name)).expect("manifest file");
Expand Down
2 changes: 1 addition & 1 deletion libduckdb-sys/duckdb-sources
Submodule duckdb-sources updated 3541 files
Binary file modified libduckdb-sys/duckdb.tar.gz
Binary file not shown.
216 changes: 211 additions & 5 deletions libduckdb-sys/src/bindgen_bundled_version.rs

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions libduckdb-sys/update_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
DUCKDB_SCRIPTS_DIR = os.path.join(SCRIPT_DIR, "duckdb-sources", "scripts")
# Path to target
TARGET_DIR = os.path.join(SCRIPT_DIR, "duckdb")
# Path to src
SRC_DIR = os.path.join(SCRIPT_DIR, "src")

# List of extensions' sources to grab. Technically, these sources will be compiled
# but not included in the final build unless they're explicitly enabled.
Expand All @@ -27,6 +29,7 @@
# Clear the duckdb directory
try:
shutil.rmtree(os.path.join(TARGET_DIR))
os.remove(os.path.join(SCRIPT_DIR, "duckdb.tar.gz"))
except FileNotFoundError:
pass

Expand Down Expand Up @@ -73,6 +76,12 @@ def get_sources(extensions):
json.dump(manifest, f, indent=2)


subprocess.check_call(
"tar -czf duckdb.tar.gz duckdb",
shell=True,
cwd=SCRIPT_DIR,
)

subprocess.check_call(
'find "' + SCRIPT_DIR + '/../target" -type f -name bindgen.rs -exec rm {} \;',
shell=True,
Expand All @@ -82,18 +91,19 @@ def get_sources(extensions):
'env LIBDUCKDB_SYS_BUNDLING=1 cargo test --features "bundled buildtime_bindgen"',
shell=True,
)

print(
'find "'
+ SCRIPT_DIR
+ '/../target" -type f -name "bindgen.rs" -exec cp {} "'
+ TARGET_DIR
+ SRC_DIR
+ '/bindgen_bundled_version.rs" \;'
)
subprocess.check_call(
'find "'
+ SCRIPT_DIR
+ '/../target" -type f -name "bindgen.rs" -exec cp {} "'
+ TARGET_DIR
+ SRC_DIR
+ '/bindgen_bundled_version.rs" \;',
shell=True,
)
Expand All @@ -104,9 +114,3 @@ def get_sources(extensions):
SCRIPT_DIR, "duckdb-sources", "extension", "httpfs", "httpfs_config.py"
)
)

subprocess.check_call(
"tar -czf duckdb.tar.gz duckdb",
shell=True,
cwd=SCRIPT_DIR,
)
6 changes: 3 additions & 3 deletions libduckdb-sys/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export DUCKDB_LIB_DIR="$SCRIPT_DIR/duckdb"
export DU_INCLUDE_DIR="$DUCKDB_LIB_DIR"

# Download and extract amalgamation
DUCKDB_VERSION=v0.7.1
git submodule update --init
DUCKDB_VERSION=v0.8.0
git submodule update --init --checkout
cd "$SCRIPT_DIR/duckdb-sources" || { echo "fatal error" >&2; exit 1; }
git checkout "$DUCKDB_VERSION"
cd "$SCRIPT_DIR" || { echo "fatal error" >&2; exit 1; }
python "$SCRIPT_DIR/update_sources.py"
python3 "$SCRIPT_DIR/update_sources.py"

# Regenerate bindgen file for DUCKDB
rm -f "$SCRIPT_DIR/src/bindgen_bundled_version.rs"
Expand Down
16 changes: 8 additions & 8 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ mod test {
{
let mut stmt = db.prepare_cached(sql)?;
assert_eq!(0, cache.len());
assert_eq!(4, stmt.query_row([], |r| r.get::<_, i64>(0))?);
assert_eq!("memory", stmt.query_row([], |r| r.get::<_, String>(1))?);
}
assert_eq!(1, cache.len());

{
let mut stmt = db.prepare_cached(sql)?;
assert_eq!(0, cache.len());
assert_eq!(4, stmt.query_row([], |r| r.get::<_, i64>(0))?);
assert_eq!("memory", stmt.query_row([], |r| r.get::<_, String>(1))?);
}
assert_eq!(1, cache.len());

Expand All @@ -231,7 +231,7 @@ mod test {
{
let mut stmt = db.prepare_cached(sql)?;
assert_eq!(0, cache.len());
assert_eq!(4, stmt.query_row([], |r| r.get::<_, i64>(0))?);
assert_eq!("memory", stmt.query_row([], |r| r.get::<_, String>(1))?);
}
assert_eq!(1, cache.len());

Expand All @@ -241,15 +241,15 @@ mod test {
{
let mut stmt = db.prepare_cached(sql)?;
assert_eq!(0, cache.len());
assert_eq!(4, stmt.query_row([], |r| r.get::<_, i64>(0))?);
assert_eq!("memory", stmt.query_row([], |r| r.get::<_, String>(1))?);
}
assert_eq!(0, cache.len());

db.set_prepared_statement_cache_capacity(8);
{
let mut stmt = db.prepare_cached(sql)?;
assert_eq!(0, cache.len());
assert_eq!(4, stmt.query_row([], |r| r.get::<_, i64>(0))?);
assert_eq!("memory", stmt.query_row([], |r| r.get::<_, String>(1))?);
}
assert_eq!(1, cache.len());
Ok(())
Expand All @@ -264,7 +264,7 @@ mod test {
{
let mut stmt = db.prepare_cached(sql)?;
assert_eq!(0, cache.len());
assert_eq!(4, stmt.query_row([], |r| r.get::<_, i64>(0))?);
assert_eq!("memory", stmt.query_row([], |r| r.get::<_, String>(1))?);
stmt.discard();
}
assert_eq!(0, cache.len());
Expand Down Expand Up @@ -325,14 +325,14 @@ mod test {
{
let mut stmt = db.prepare_cached(sql)?;
assert_eq!(0, cache.len());
assert_eq!(4, stmt.query_row([], |r| r.get::<_, i64>(0))?);
assert_eq!("memory", stmt.query_row([], |r| r.get::<_, String>(1))?);
}
assert_eq!(1, cache.len());

{
let mut stmt = db.prepare_cached(sql)?;
assert_eq!(0, cache.len());
assert_eq!(4, stmt.query_row([], |r| r.get::<_, i64>(0))?);
assert_eq!("memory", stmt.query_row([], |r| r.get::<_, String>(1))?);
}
assert_eq!(1, cache.len());
Ok(())
Expand Down
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ mod test {
.collect();
let val = val?;
let mut iter = val.iter();
assert!(iter.next().unwrap().is_none());
assert_eq!(val.len(), 4);
assert_eq!(iter.next().unwrap().as_ref().unwrap(), "a");
assert_eq!(iter.next().unwrap().as_ref().unwrap(), "b");
assert_eq!(iter.next().unwrap().as_ref().unwrap(), "c");
assert!(iter.next().unwrap().is_none());
assert_eq!(iter.next(), None);

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ mod test {
db.execute_batch(
r"
CREATE TABLE foo (x INTEGER);
SET AUTOCOMMIT TO OFF;
-- SET AUTOCOMMIT TO OFF;
",
)?;
Ok(db)
Expand Down
7 changes: 4 additions & 3 deletions src/vtab/excel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl VTab for ExcelVTab {
#[cfg(test)]
mod test {
use crate::{vtab::excel::ExcelVTab, Connection, Result};
use arrow::array::{Array, Date32Array, Float64Array, StringArray};
use arrow::array::{Array, Date32Array, Float64Array, LargeStringArray};
use std::error::Error;

#[test]
Expand All @@ -204,7 +204,6 @@ mod test {
.query_row::<i64, _, _>([], |row| row.get(0))?;
assert_eq!(3039, val);
let mut stmt = db.prepare("select genres, sum(movie_facebook_likes) from excel('./examples/Movies_Social_metadata.xlsx', 'Data') group by genres order by genres limit 4")?;
let mut arr = stmt.query_arrow([])?;
// +-------------+---------------------------+
// | genres | sum(movie_facebook_likes) |
// +-------------+---------------------------+
Expand All @@ -213,8 +212,10 @@ mod test {
// | Animation | 202219.0 |
// | Biography | 1724632.0 |
// +-------------+---------------------------+
let mut arr = stmt.query_arrow([])?;
let rb = arr.next().expect("no record batch");
let column = rb.column(0).as_any().downcast_ref::<StringArray>().unwrap();
assert_eq!(rb.num_rows(), 4);
let column = rb.column(0).as_any().downcast_ref::<LargeStringArray>().unwrap();
assert_eq!(column.len(), 4);
assert_eq!(column.value(0), "Action");
assert_eq!(column.value(1), "Adventure");
Expand Down

0 comments on commit cfda58b

Please sign in to comment.