guojidan commented on issue #15756:
URL: https://github.com/apache/datafusion/issues/15756#issuecomment-2817457411
```
use std::sync::Arc;
use bytes::Bytes;
use datafusion::prelude::{CsvReadOptions, SessionContext};
use object_store::{memory::InMemory, path::Path, ObjectStore};
use url::Url;
#[tokio::main]
async fn main() {
let ctx = SessionContext::new();
let bucket_name = "nyc-tlc";
let store: Arc<dyn ObjectStore> = Arc::new(InMemory::new());
let data = r#""year"╦"gender"╦"ethnicity"╦"firstname"╦"count"╦"rank"
"2011"╦"FEMALE"╦"ASIAN AND PACIFIC ISLANDER"╦"SOPHIA"╦"119"╦"1"
"2011"╦"FEMALE"╦"ASIAN AND PACIFIC ISLANDER"╦"CHLOE"╦"106"╦"2"
"2011"╦"FEMALE"╦"ASIAN AND PACIFIC ISLANDER"╦"EMILY"╦"93"╦"3"
"2011"╦"FEMALE"╦"ASIAN AND PACIFIC ISLANDER"╦"OLIVIA"╦"89"╦"4"
"2011"╦"FEMALE"╦"ASIAN AND PACIFIC ISLANDER"╦"EMMA"╦"75"╦"5"
"2011"╦"FEMALE"╦"ASIAN AND PACIFIC ISLANDER"╦"ISABELLA"╦"67"╦"6"
"2011"╦"FEMALE"╦"ASIAN AND PACIFIC ISLANDER"╦"TIFFANY"╦"54"╦"7"
"2011"╦"FEMALE"╦"ASIAN AND PACIFIC ISLANDER"╦"ASHLEY"╦"52"╦"8"
"2011"╦"FEMALE"╦"ASIAN AND PACIFIC ISLANDER"╦"FIONA"╦"48"╦"9"
"2011"╦"FEMALE"╦"ASIAN AND PACIFIC ISLANDER"╦"ANGELA"╦"47"╦"10""#;
let data_bytes = Bytes::from(data);
let path = Path::from("test.csv");
store.put(&path, data_bytes.into()).await.unwrap();
let path = format!("s3://{bucket_name}");
let s3_url = Url::parse(&path).unwrap();
ctx.register_object_store(&s3_url, Arc::new(store));
let path = format!("s3://{bucket_name}/test.csv");
let opts = CsvReadOptions {
delimiter: "╦".as_bytes().first().copied().unwrap_or_default(),
..Default::default()
};
ctx.register_csv("trips", &path, opts)
.await.unwrap();
let df = ctx.sql("SELECT * FROM trips LIMIT 10").await.unwrap();
// print the results
df.show().await.unwrap();
}
```
got error:
```
thread 'main' panicked at
datafusion-examples/examples/external_dependency/test_utf8.rs:40:16:
called `Result::unwrap()` on an `Err` value: Context("Error when processing
CSV file test.csv", ArrowError(CsvError("Encountered UTF-8 error while reading
CSV file: invalid utf-8: invalid UTF-8 in field 1 near byte index 0 at line
1"), None))
stack backtrace:
0: rust_begin_unwind
at
/rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/panicking.rs:692:5
1: core::panicking::panic_fmt
at
/rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/panicking.rs:75:14
2: core::result::unwrap_failed
at
/rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/result.rs:1704:5
3: core::result::Result<T,E>::unwrap
at
/home/dandan/.rustup/toolchains/1.85.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1109:23
4: test_utf8::main::{{closure}}
at
./datafusion-examples/examples/external_dependency/test_utf8.rs:39:5
5: <core::pin::Pin<P> as core::future::future::Future>::poll
at
/home/dandan/.rustup/toolchains/1.85.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9
6: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
at
/home/dandan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.43.0/src/runtime/park.rs:284:63
7: tokio::runtime::coop::with_budget
at
/home/dandan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.43.0/src/runtime/coop.rs:107:5
8: tokio::runtime::coop::budget
at
/home/dandan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.43.0/src/runtime/coop.rs:73:5
9: tokio::runtime::park::CachedParkThread::block_on
at
/home/dandan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.43.0/src/runtime/park.rs:284:31
10: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
at
/home/dandan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.43.0/src/runtime/context/blocking.rs:66:9
11:
tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
at
/home/dandan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.43.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
12: tokio::runtime::context::runtime::enter_runtime
at
/home/dandan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.43.0/src/runtime/context/runtime.rs:65:16
13: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
at
/home/dandan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.43.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
14: tokio::runtime::runtime::Runtime::block_on_inner
at
/home/dandan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.43.0/src/runtime/runtime.rs:370:45
15: tokio::runtime::runtime::Runtime::block_on
at
/home/dandan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.43.0/src/runtime/runtime.rs:340:13
16: test_utf8::main
at
./datafusion-examples/examples/external_dependency/test_utf8.rs:45:5
```
@jayzhan211
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]