Skip to content

Commit 4591734

Browse files
committed
Add e2e ci test
1 parent faac3bc commit 4591734

File tree

5 files changed

+68
-5
lines changed

5 files changed

+68
-5
lines changed

datafusion-cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ url = "2.2"
6565
assert_cmd = "2.0"
6666
ctor = "0.2.0"
6767
predicates = "3.0"
68-
rstest = "0.17"
68+
rstest = "0.17"

datafusion-cli/src/hf_store.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ impl ObjectStore for HFStore {
607607
let file_path_prefix = parsed_url.file_path_prefix();
608608

609609
futures::stream::once(async move {
610-
let result = self.store.get(&Path::from(tree_path)).await?;
610+
let result = self.store.get(&Path::parse(tree_path)?).await?;
611611
let Ok(bytes) = result.bytes().await else {
612612
return Err(ObjectStoreError::Generic {
613613
store: STORE,
@@ -630,7 +630,7 @@ impl ObjectStore for HFStore {
630630
.filter(|entry| entry.is_file())
631631
.map(|entry| format!("{}/{}", file_path_prefix, entry.path.clone()))
632632
.map(|meta_location| async {
633-
self.store.head(&Path::from(meta_location)).await
633+
self.store.head(&Path::parse(meta_location)?).await
634634
}),
635635
)
636636
.await
@@ -646,9 +646,10 @@ impl ObjectStore for HFStore {
646646
.into(),
647647
});
648648
};
649-
meta.location = Path::from(location.hf_path());
649+
650+
meta.location = Path::from_url_path(location.hf_path())?;
650651
if let Some(e_tag) = meta.e_tag.as_deref() {
651-
meta.e_tag = Some(e_tag.replace("\"", ""));
652+
meta.e_tag = Some(e_tag.replace('"', ""));
652653
}
653654

654655
Ok(meta)

datafusion-cli/tests/cli_integration.rs

+33
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
use std::fs;
1819
use std::process::Command;
1920

2021
use assert_cmd::prelude::{CommandCargoExt, OutputAssertExt};
@@ -54,3 +55,35 @@ fn cli_quick_test<'a>(
5455
cmd.args(args);
5556
cmd.assert().stdout(predicate::eq(expected));
5657
}
58+
59+
#[rstest]
60+
#[case::exec_hf_store_test(
61+
["--file", "tests/data/hf_store_sql.txt", "--format", "json", "-q"],
62+
"tests/data/hf_store_expected.jsonl",
63+
)]
64+
#[test]
65+
fn cli_hf_store_test<'a>(
66+
#[case] args: impl IntoIterator<Item = &'a str>,
67+
#[case] expected_file: &str,
68+
) {
69+
let mut cmd = Command::cargo_bin("datafusion-cli").unwrap();
70+
cmd.args(args);
71+
72+
let actual: Vec<serde_json::Value> = serde_json::Deserializer::from_str(
73+
String::from_utf8(cmd.assert().get_output().stdout.to_vec())
74+
.unwrap()
75+
.as_str(),
76+
)
77+
.into_iter::<serde_json::Value>()
78+
.collect::<Result<Vec<serde_json::Value>, _>>()
79+
.unwrap();
80+
81+
let expected: Vec<serde_json::Value> = serde_json::Deserializer::from_str(
82+
fs::read_to_string(expected_file).unwrap().as_str(),
83+
)
84+
.into_iter::<serde_json::Value>()
85+
.collect::<Result<Vec<serde_json::Value>, _>>()
86+
.unwrap();
87+
88+
assert_eq!(actual, expected);
89+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"COUNT(*)": 5
4+
}
5+
]
6+
[
7+
{
8+
"COUNT(*)": 152
9+
}
10+
]
11+
[
12+
{
13+
"COUNT(*)": 173
14+
}
15+
]
16+
[
17+
{
18+
"COUNT(*)": 152
19+
}
20+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
select count(*) from "hf://datasets/cais/mmlu/astronomy/dev-00000-of-00001.parquet";
2+
3+
select count(*) from "hf://datasets/cais/mmlu@~parquet/astronomy/test/0000.parquet";
4+
5+
create external table test stored as parquet location "hf://datasets/cais/mmlu/astronomy/";
6+
SELECT count(*) FROM test;
7+
8+
create external table test_revision stored as parquet location "hf://datasets/cais/mmlu@~parquet/astronomy/test/";
9+
SELECT count(*) FROM test_revision;

0 commit comments

Comments
 (0)