Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leading x00 byte when querying BIT value using arrow #349

Open
pshampanier opened this issue Jul 3, 2024 · 1 comment
Open

Leading x00 byte when querying BIT value using arrow #349

pshampanier opened this issue Jul 3, 2024 · 1 comment

Comments

@pshampanier
Copy link

pshampanier commented Jul 3, 2024

When I query the following BIT value '11011110101011011011111011101111' using arrow, I'm getting an extra leading byte with the value x00.

'11011110101011011011111011101111' is 32 bits and expected to be (\xDE\xAD\xBE\xEF) shown by the following query run from the duckdb CLI:

SELECT '11011110101011011011111011101111'::BIT::BLOB;
┌───────────────────────────────────────────────────────────────┐
│ CAST(CAST('11011110101011011011111011101111' AS BIT) AS BLOB) │
│                             blob                              │
├───────────────────────────────────────────────────────────────┤
│ \xDE\xAD\xBE\xEF                                              │
└───────────────────────────────────────────────────────────────┘

But when running the following code I'm getting a result of 5 bytes:

use duckdb::{params, Connection};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let conn = Connection::open_in_memory()?;
    let mut stmt = conn.prepare("SELECT '11011110101011011011111011101111'::BIT")?;
    let result = stmt.query_arrow(params![])?;
    println!("{:?}", result.collect::<Vec<_>>());
    Ok(())
}
[RecordBatch { schema: Schema { fields: [Field { name: "CAST('11011110101011011011111011101111' AS BIT)", data_type: Binary, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }], metadata: {} }, columns: [BinaryArray
[
  [0, 222, 173, 190, 239],
]], row_count: 1 }]

The expected result is [222, 173, 190, 239].

Note

rustc 1.75.0 (82e1608df 2023-12-21)
duckdb = "0.10.2"

@pshampanier
Copy link
Author

Issue still there with duckdb = "1.0.0".

Note

rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-apple-darwin
release: 1.75.0
LLVM version: 17.0.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant