Skip to content

Commit 2995cac

Browse files
committed
test: arrow_path_to_parquet
1 parent 41b3688 commit 2995cac

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

src/parseable/streams.rs

+64
Original file line numberDiff line numberDiff line change
@@ -1230,4 +1230,68 @@ mod tests {
12301230
assert_eq!(staging.parquet_files().len(), 2);
12311231
assert_eq!(staging.arrow_files().len(), 1);
12321232
}
1233+
1234+
#[test]
1235+
fn test_valid_arrow_path_conversion() {
1236+
let path = Path::new("/tmp/12345abcde&key1=value1.date=2020-01-21.hour=10.minute=30.key1=value1.key2=value2.ee529ffc8e76.data.arrows");
1237+
let random_string = "random123";
1238+
1239+
let result = arrow_path_to_parquet(path, random_string);
1240+
1241+
assert!(result.is_some());
1242+
let parquet_path = result.unwrap();
1243+
assert_eq!(
1244+
parquet_path.to_str().unwrap(),
1245+
"/tmp/date=2020-01-21.hour=10.minute=30.key1=value1.key2=value2.ee529ffc8e76.data.random123.parquet"
1246+
);
1247+
}
1248+
1249+
#[test]
1250+
fn test_invalid_arrow_path() {
1251+
// Missing the ".data.arrows" suffix
1252+
let path = Path::new("/tmp/12345abcde&key1=value1.date=2020-01-21.hour=10.minute=30");
1253+
let random_string = "random123";
1254+
1255+
let result = arrow_path_to_parquet(path, random_string);
1256+
1257+
assert!(result.is_none());
1258+
}
1259+
1260+
#[test]
1261+
fn test_invalid_schema_key() {
1262+
// Invalid schema key with special characters
1263+
let path =
1264+
Path::new("/tmp/12345abcde&key1=value1!.date=2020-01-21.hour=10.minute=30.data.arrows");
1265+
let random_string = "random123";
1266+
1267+
let result = arrow_path_to_parquet(path, random_string);
1268+
1269+
assert!(result.is_none());
1270+
}
1271+
1272+
#[test]
1273+
fn test_complex_path() {
1274+
let path = Path::new("/nested/directory/structure/20200201T1830f8a5fc1edc567d56&key1=value1&key2=value2.date=2020-01-21.hour=10.minute=30.region=us-west.ee529ffc8e76.data.arrows");
1275+
let random_string = "random456";
1276+
1277+
let result = arrow_path_to_parquet(path, random_string);
1278+
1279+
assert!(result.is_some());
1280+
let parquet_path = result.unwrap();
1281+
assert_eq!(
1282+
parquet_path.to_str().unwrap(),
1283+
"/nested/directory/structure/date=2020-01-21.hour=10.minute=30.region=us-west.ee529ffc8e76.data.random456.parquet"
1284+
);
1285+
}
1286+
1287+
#[test]
1288+
fn test_empty_front_part() {
1289+
// Valid but with empty front part
1290+
let path = Path::new("/tmp/schema_key..data.arrows");
1291+
let random_string = "random789";
1292+
1293+
let result = arrow_path_to_parquet(path, random_string);
1294+
1295+
assert!(result.is_none());
1296+
}
12331297
}

0 commit comments

Comments
 (0)