goldmedal commented on code in PR #12263:
URL: https://github.com/apache/datafusion/pull/12263#discussion_r1743863746
##########
datafusion/core/src/datasource/physical_plan/csv.rs:
##########
@@ -1210,6 +1242,105 @@ mod tests {
crate::assert_batches_eq!(expected, &result);
}
+ #[tokio::test]
+ async fn test_terminator() {
+ let session_ctx = SessionContext::new();
+ let store = object_store::memory::InMemory::new();
+
+ let data = bytes::Bytes::from("a,b\r1,2\r3,4");
+ let path = object_store::path::Path::from("a.csv");
+ store.put(&path, data.into()).await.unwrap();
+
+ let url = Url::parse("memory://").unwrap();
+ session_ctx.register_object_store(&url, Arc::new(store));
+
+ let df = session_ctx
+ .read_csv("memory:///",
CsvReadOptions::new().terminator(Some(b'\r')))
+ .await
+ .unwrap();
+
+ let result = df.collect().await.unwrap();
+
+ let expected = [
+ "+---+---+",
+ "| a | b |",
+ "+---+---+",
+ "| 1 | 2 |",
+ "| 3 | 4 |",
+ "+---+---+",
+ ];
+
+ crate::assert_batches_eq!(expected, &result);
+
+ match session_ctx
+ .read_csv("memory:///",
CsvReadOptions::new().terminator(Some(b'\n')))
+ .await.unwrap().collect().await {
+ Ok(_) => panic!("Expected error"),
+ Err(e) => assert_eq!(e.strip_backtrace(), "Arrow error: Csv error:
incorrect number of fields for line 1, expected 2 got more than 2"),
Review Comment:
Thanks! It looks better.
--
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]