Skip to content

Commit 7550e24

Browse files
committed
FIX: Fix batch job deserializing
1 parent 23c6e6d commit 7550e24

File tree

2 files changed

+76
-8
lines changed

2 files changed

+76
-8
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 0.26.3 - TBD
4+
5+
### Bug fixes
6+
- Fixed bug with deserializing `null` `split_duration` in historical
7+
`batch().list_jobs()`
8+
9+
### Bug fixes
10+
- Fixed bug with deserializing `null` `split_duration` in historical
11+
`batch().list_jobs()`
12+
313
## 0.26.2 - 2025-06-03
414

515
### Enhancements

src/historical/batch.rs

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ impl BatchClient<'_> {
5151
("pretty_ts", params.pretty_ts.to_string()),
5252
("map_symbols", params.map_symbols.to_string()),
5353
("split_symbols", params.split_symbols.to_string()),
54-
("split_duration", params.split_duration.to_string()),
5554
("delivery", params.delivery.to_string()),
5655
("stype_in", params.stype_in.to_string()),
5756
("stype_out", params.stype_out.to_string()),
@@ -64,6 +63,9 @@ impl BatchClient<'_> {
6463
if let Some(limit) = params.limit {
6564
form.push(("limit", limit.to_string()));
6665
}
66+
if let Some(split_duration) = params.split_duration {
67+
form.push(("split_duration", split_duration.to_string()));
68+
}
6769
let builder = self.post("submit_job")?.form(&form);
6870
let resp = builder.send().await?;
6971
handle_response(resp).await
@@ -270,10 +272,11 @@ pub struct SubmitJobParams {
270272
/// If `true`, files will be split by raw symbol. Cannot be requested with [`Symbols::All`].
271273
#[builder(default)]
272274
pub split_symbols: bool,
273-
/// The maximum time duration before batched data is split into multiple files.
274-
/// Defaults to [`Day`](SplitDuration::Day).
275-
#[builder(default)]
276-
pub split_duration: SplitDuration,
275+
/// The maximum time duration before batched data is split into multiple
276+
/// files. If `None` the data will not be split by time. Defaults to
277+
/// [`Day`](SplitDuration::Day).
278+
#[builder(default = Some(SplitDuration::default()))]
279+
pub split_duration: Option<SplitDuration>,
277280
/// The optional maximum size (in bytes) of each batched data file before being split.
278281
/// Must be an integer between 1e9 and 10e9 inclusive (1GB - 10GB). Defaults to `None`.
279282
#[builder(default, setter(strip_option))]
@@ -339,7 +342,7 @@ pub struct BatchJob {
339342
pub split_symbols: bool,
340343
/// The maximum time interval for an individual file before splitting into multiple
341344
/// files.
342-
pub split_duration: SplitDuration,
345+
pub split_duration: Option<SplitDuration>,
343346
/// The maximum size for an individual file before splitting into multiple files.
344347
pub split_size: Option<NonZeroU64>,
345348
/// The delivery mechanism of the batch data.
@@ -689,6 +692,41 @@ mod tests {
689692
"ts_process_start": "2023-07-19 23:01:04.000000+00:00",
690693
"ts_process_done": null,
691694
"ts_expiration": null
695+
},
696+
{
697+
"id": "XNAS-20250602-5KM3HL5BUW",
698+
"user_id": "AA89XSlBV",
699+
"bill_id": null,
700+
"cost_usd": 0.0,
701+
"dataset": "XNAS.ITCH",
702+
"symbols": "MSFT",
703+
"stype_in": "raw_symbol",
704+
"stype_out": "instrument_id",
705+
"schema": "trades",
706+
"start": "2022-06-10T12:30:00.000000000Z",
707+
"end": "2022-06-10T14:00:00.000000000Z",
708+
"limit": 1000,
709+
"encoding": "csv",
710+
"compression": null,
711+
"pretty_px": false,
712+
"pretty_ts": false,
713+
"map_symbols": true,
714+
"split_symbols": false,
715+
"split_duration": null,
716+
"split_size": null,
717+
"packaging": null,
718+
"delivery": "download",
719+
"record_count": 1000,
720+
"billed_size": 48000,
721+
"actual_size": 94000,
722+
"package_size": 97690,
723+
"state": "done",
724+
"ts_received": "2025-06-02T15:51:19.251582000Z",
725+
"ts_queued": "2025-06-02T15:51:20.997673000Z",
726+
"ts_process_start": "2025-06-02T15:51:45.312317000Z",
727+
"ts_process_done": "2025-06-02T15:51:46.324860000Z",
728+
"ts_expiration": "2025-07-02T16:00:00.000000000Z",
729+
"progress": 100
692730
}])),
693731
)
694732
.mount(&mock_server)
@@ -699,8 +737,8 @@ mod tests {
699737
HistoricalGateway::Bo1,
700738
)?;
701739
let job_descs = target.batch().list_jobs(&ListJobsParams::default()).await?;
702-
assert_eq!(job_descs.len(), 1);
703-
let job_desc = &job_descs[0];
740+
assert_eq!(job_descs.len(), 2);
741+
let mut job_desc = &job_descs[0];
704742
assert_eq!(
705743
job_desc.ts_queued.unwrap(),
706744
datetime!(2023-07-19 23:00:08.095538123 UTC)
@@ -713,6 +751,26 @@ mod tests {
713751
assert!(job_desc.pretty_px);
714752
assert!(!job_desc.pretty_ts);
715753
assert!(job_desc.map_symbols);
754+
assert_eq!(job_desc.split_duration, Some(SplitDuration::Day));
755+
756+
job_desc = &job_descs[1];
757+
assert_eq!(
758+
job_desc.ts_queued.unwrap(),
759+
datetime!(2025-06-02 15:51:20.997673000 UTC)
760+
);
761+
assert_eq!(
762+
job_desc.ts_process_start.unwrap(),
763+
datetime!(2025-06-02 15:51:45.312317000 UTC)
764+
);
765+
assert_eq!(job_desc.start, datetime!(2022-06-10 12:30:00.000000000 UTC));
766+
assert_eq!(job_desc.end, datetime!(2022-06-10 14:00:00.000000000 UTC));
767+
assert_eq!(job_desc.encoding, Encoding::Csv);
768+
assert!(!job_desc.pretty_px);
769+
assert!(!job_desc.pretty_ts);
770+
assert!(job_desc.map_symbols);
771+
assert!(!job_desc.split_symbols);
772+
assert_eq!(job_desc.split_duration, None);
773+
716774
Ok(())
717775
}
718776

0 commit comments

Comments
 (0)