Skip to content

Commit 6430076

Browse files
Maxxenluong-komorebiyutannihilationshriteshfotonick
authored
[WIP] Upgrade to V1.2.1 (#462)
* fix: pin duckdb and libduckdb-sys versions Signed-off-by: luong-hq <[email protected]> * Bump arrow to the version compatible with chrono 0.4.40 * Update only arrow * Fix minor typo * Do not pass stdlib * Fix #380, bug in code that reads Enums In turning a ValueRef to a Value, the code was indexing with the row index directly into the dictionary's string array, so iterating any query's results was effectively just listing the Enum variants in order until row index > number of variants and it panicked. Fix by getting the row value (key) and using that to index into the dictionary's string array. * Fix incorrect Enum test The test tests for correct value extraction, based on built-in examples in DuckDB. The old expected value was flatly incorrect, as can be seen in duckdb directly with `SELECT medium_enum FROM test_all_types();`. * Fix writing Arrow Decimal128 with zero scale * Fix CI install of rustfmt and clippy Extra space breaks hecrj/setup-rust-action. Arguments should be comma-separated. * update duckdb to v1.2.1 * replace rust toolchain action * fix warnings * add back sanitizer * move logicaltypeid * add correct component for asan * add back extensions to asan build * bundle ICU as part of extensions-full --------- Signed-off-by: luong-hq <[email protected]> Co-authored-by: luong-hq <[email protected]> Co-authored-by: Hiroaki Yutani <[email protected]> Co-authored-by: Shritesh Bhattarai <[email protected]> Co-authored-by: Nickolas Fotopoulos <[email protected]> Co-authored-by: sgrebnov <[email protected]>
1 parent 1096461 commit 6430076

File tree

21 files changed

+102
-1766
lines changed

21 files changed

+102
-1766
lines changed

.github/workflows/release.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v2
14-
# This has a matcher for test panics, so we use it even though elsewhere
15-
# we use actions-rs/toolchain.
16-
- uses: hecrj/setup-rust-action@v1
14+
- uses: actions-rust-lang/setup-rust-toolchain@v1
1715
with:
18-
rust-version: stable${{ matrix.host }}
19-
targets: ${{ matrix.target }}
16+
toolchain: stable
17+
target: ${{ matrix.target }}
2018
components: 'rustfmt, clippy'
2119

2220
# cargo publish

.github/workflows/rust.yaml

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,18 @@ jobs:
2626
runs-on: ${{ matrix.os }}
2727
steps:
2828
- uses: actions/checkout@v2
29-
# This has a matcher for test panics, so we use it even though elsewhere
30-
# we use actions-rs/toolchain.
31-
- uses: hecrj/setup-rust-action@v1
29+
- uses: actions-rust-lang/setup-rust-toolchain@v1
3230
with:
33-
rust-version: stable${{ matrix.host }}
34-
targets: ${{ matrix.target }}
31+
toolchain: stable
32+
target: ${{ matrix.target }}
3533
components: 'rustfmt, clippy'
3634

3735
# download libduckdb
3836
- uses: robinraju/[email protected]
3937
name: Download duckdb
4038
with:
4139
repository: "duckdb/duckdb"
42-
tag: "v1.2.0"
40+
tag: "v1.2.1"
4341
fileName: ${{ matrix.duckdb }}
4442
out-file-path: .
4543

@@ -112,9 +110,41 @@ jobs:
112110
key: index-${{ runner.os }}-${{ github.run_number }}
113111
restore-keys: |
114112
index-${{ runner.os }}-
115-
- uses: hecrj/setup-rust-action@v1
113+
- uses: actions-rust-lang/setup-rust-toolchain@v1
116114
with:
117-
rust-version: stable
118-
targets: x86_64-pc-windows-msvc
115+
toolchain: stable
116+
target: x86_64-pc-windows-msvc
119117

120-
- run: cargo install cargo-examples
118+
- run: cargo install cargo-examples
119+
120+
Sanitizer:
121+
name: Address Sanitizer
122+
needs: test
123+
runs-on: ubuntu-latest
124+
steps:
125+
- uses: actions/checkout@v2
126+
# Need nightly rust.
127+
- uses: actions-rust-lang/setup-rust-toolchain@v1
128+
with:
129+
toolchain: nightly
130+
components: 'rust-src'
131+
132+
- name: Tests with asan
133+
env:
134+
RUSTFLAGS: -Zsanitizer=address -C debuginfo=0
135+
RUSTDOCFLAGS: -Zsanitizer=address
136+
ASAN_OPTIONS: "detect_stack_use_after_return=1:detect_leaks=1"
137+
# Work around https://github.com/rust-lang/rust/issues/59125 by
138+
# disabling backtraces. In an ideal world we'd probably suppress the
139+
# leak sanitization, but we don't care about backtraces here, so long
140+
# as the other tests have them.
141+
RUST_BACKTRACE: "0"
142+
run: |
143+
cargo -Z build-std test --features "modern-full extensions-full" --target x86_64-unknown-linux-gnu --package duckdb
144+
- name: publish crates --dry-run
145+
uses: katyo/publish-crates@v2
146+
with:
147+
path: './'
148+
args: --allow-dirty --all-features
149+
dry-run: true
150+
ignore-unpublished-changes: true

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ members = [
77
]
88

99
[workspace.package]
10-
version = "1.2.0"
10+
version = "1.2.1"
1111
authors = ["wangfenjin <[email protected]>"]
1212
edition = "2021"
1313
repository = "https://github.com/duckdb/duckdb-rs"
@@ -19,9 +19,9 @@ license = "MIT"
1919
categories = ["database"]
2020

2121
[workspace.dependencies]
22-
duckdb = { version = "1.2.0", path = "crates/duckdb" }
23-
libduckdb-sys = { version = "1.2.0", path = "crates/libduckdb-sys" }
24-
duckdb-loadable-macros = { version = "0.1.4", path = "crates/duckdb-loadable-macros" }
22+
duckdb = { version = "=1.2.1", path = "crates/duckdb" }
23+
libduckdb-sys = { version = "=1.2.1", path = "crates/libduckdb-sys" }
24+
duckdb-loadable-macros = { version = "=0.1.5", path = "crates/duckdb-loadable-macros" }
2525
autocfg = "1.0"
2626
bindgen = { version = "0.71.1", default-features = false }
2727
byteorder = "1.3"
@@ -63,4 +63,4 @@ unicase = "2.6.0"
6363
url = "2.1"
6464
uuid = "1.0"
6565
vcpkg = "0.2"
66-
arrow = { version = "54", default-features = false }
66+
arrow = { version = "54.2.1", default-features = false }

crates/duckdb-loadable-macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "duckdb-loadable-macros"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true

crates/duckdb/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "duckdb"
3-
version = "1.2.0"
3+
version = "1.2.1"
44
authors.workspace = true
55
edition.workspace = true
66
repository.workspace = true
@@ -22,6 +22,7 @@ default = []
2222
bundled = ["libduckdb-sys/bundled"]
2323
json = ["libduckdb-sys/json", "bundled"]
2424
parquet = ["libduckdb-sys/parquet", "bundled"]
25+
icu = ["libduckdb-sys/icu", "bundled"]
2526
vscalar = []
2627
vscalar-arrow = []
2728
vtab = []
@@ -30,7 +31,7 @@ vtab-excel = ["vtab", "calamine"]
3031
vtab-arrow = ["vtab", "num"]
3132
appender-arrow = ["vtab-arrow"]
3233
vtab-full = ["vtab-excel", "vtab-arrow", "appender-arrow"]
33-
extensions-full = ["json", "parquet", "vtab-full"]
34+
extensions-full = ["json", "parquet", "icu", "vtab-full"]
3435
buildtime_bindgen = ["libduckdb-sys/buildtime_bindgen"]
3536
modern-full = ["chrono", "serde_json", "url", "r2d2", "uuid", "polars"]
3637
polars = ["dep:polars", "dep:polars-arrow"]

crates/duckdb/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub mod types;
126126
#[cfg(feature = "vtab")]
127127
pub mod vtab;
128128

129-
/// The duckdb table function interface
129+
/// The duckdb scalar function interface
130130
#[cfg(feature = "vscalar")]
131131
pub mod vscalar;
132132

crates/duckdb/src/test_all_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ fn test_single(idx: &mut i32, column: String, value: ValueRef) {
651651
},
652652
"medium_enum" => match idx {
653653
0 => assert_eq!(value.to_owned(), Value::Enum("enum_0".to_string())),
654-
1 => assert_eq!(value.to_owned(), Value::Enum("enum_1".to_string())),
654+
1 => assert_eq!(value.to_owned(), Value::Enum("enum_299".to_string())),
655655
_ => assert_eq!(value, ValueRef::Null),
656656
},
657657
"large_enum" => match idx {

crates/duckdb/src/types/string.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub struct DuckString<'a> {
66
}
77

88
impl<'a> DuckString<'a> {
9+
#[allow(dead_code)]
910
pub(crate) fn new(ptr: &'a mut duckdb_string_t) -> Self {
1011
DuckString { ptr }
1112
}

crates/duckdb/src/types/value_ref.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use rust_decimal::prelude::*;
66

77
use arrow::{
88
array::{
9-
Array, ArrayRef, DictionaryArray, FixedSizeListArray, LargeListArray, ListArray, MapArray, StructArray,
10-
UnionArray,
9+
Array, ArrayRef, DictionaryArray, FixedSizeListArray, LargeListArray, ListArray, MapArray, StringArray,
10+
StructArray, UnionArray,
1111
},
1212
datatypes::{UInt16Type, UInt32Type, UInt8Type},
1313
};
@@ -239,22 +239,21 @@ impl From<ValueRef<'_>> for Value {
239239
}
240240
},
241241
ValueRef::Enum(items, idx) => {
242-
let value = Row::value_ref_internal(
243-
idx,
244-
0,
245-
match items {
246-
EnumType::UInt8(res) => res.values(),
247-
EnumType::UInt16(res) => res.values(),
248-
EnumType::UInt32(res) => res.values(),
249-
},
250-
)
251-
.to_owned();
252-
253-
if let Value::Text(s) = value {
254-
Value::Enum(s)
255-
} else {
256-
panic!("Enum value is not a string")
242+
let dict_values = match items {
243+
EnumType::UInt8(res) => res.values(),
244+
EnumType::UInt16(res) => res.values(),
245+
EnumType::UInt32(res) => res.values(),
246+
}
247+
.as_any()
248+
.downcast_ref::<StringArray>()
249+
.expect("Enum value is not a string");
250+
let dict_key = match items {
251+
EnumType::UInt8(res) => res.key(idx),
252+
EnumType::UInt16(res) => res.key(idx),
253+
EnumType::UInt32(res) => res.key(idx),
257254
}
255+
.unwrap();
256+
Value::Enum(dict_values.value(dict_key).to_string())
258257
}
259258
ValueRef::Struct(items, idx) => {
260259
let value: Vec<(String, Value)> = items

crates/duckdb/src/vscalar/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
};
1515
mod function;
1616

17-
/// The duckdb Arrow table function interface
17+
/// The duckdb Arrow scalar function interface
1818
#[cfg(feature = "vscalar-arrow")]
1919
pub mod arrow;
2020

@@ -32,7 +32,7 @@ pub trait VScalar: Sized {
3232
///
3333
/// This function is unsafe because it:
3434
///
35-
/// - Dereferences multiple raw pointers (`func``).
35+
/// - Dereferences multiple raw pointers (`func`).
3636
///
3737
unsafe fn invoke(
3838
state: &Self::State,

0 commit comments

Comments
 (0)