Skip to content

Commit 96af702

Browse files
author
Devdutt Shenoi
committed
feat: re-enable time-partitioning
1 parent f10d606 commit 96af702

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/event/format/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl EventFormat for Event {
179179
origin_size,
180180
is_first_event,
181181
parsed_timestamp,
182-
time_partition: None,
182+
time_partitioned: time_partition.is_some(),
183183
custom_partition_values,
184184
stream_type,
185185
})

src/event/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::{
3131
storage::StreamType,
3232
LOCK_EXPECT,
3333
};
34-
use chrono::NaiveDateTime;
34+
use chrono::{NaiveDateTime, Utc};
3535
use std::collections::HashMap;
3636

3737
pub const DEFAULT_TIMESTAMP_KEY: &str = "p_timestamp";
@@ -47,7 +47,7 @@ pub struct Event {
4747
pub origin_size: u64,
4848
pub is_first_event: bool,
4949
pub parsed_timestamp: NaiveDateTime,
50-
pub time_partition: Option<String>,
50+
pub time_partitioned: bool,
5151
pub custom_partition_values: HashMap<String, String>,
5252
pub stream_type: StreamType,
5353
}
@@ -56,12 +56,14 @@ pub struct Event {
5656
impl Event {
5757
pub fn process(self) -> Result<(), EventError> {
5858
let mut key = get_schema_key(&self.rb.schema().fields);
59-
if self.time_partition.is_some() {
60-
let parsed_timestamp_to_min = self.parsed_timestamp.format("%Y%m%dT%H%M").to_string();
61-
key.push_str(&parsed_timestamp_to_min);
59+
if self.time_partitioned {
60+
// For time partitioned streams, concatenate timestamp to filename, ensuring we don't write to a finished arrows file
61+
let curr_timestamp = Utc::now().format("%Y%m%dT%H%M").to_string();
62+
key.push_str(&curr_timestamp);
6263
}
6364

6465
if !self.custom_partition_values.is_empty() {
66+
// For custom partitioned streams, concatenate values to filename, ensuring we write to different arrows files
6567
for (k, v) in self.custom_partition_values.iter().sorted_by_key(|v| v.0) {
6668
key.push_str(&format!("&{k}={v}"));
6769
}

src/handlers/http/ingest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ pub async fn push_logs_unchecked(
296296
origin_format: "json",
297297
origin_size: 0,
298298
parsed_timestamp: Utc::now().naive_utc(),
299-
time_partition: None,
299+
time_partitioned: false,
300300
is_first_event: true, // NOTE: Maybe should be false
301301
custom_partition_values: HashMap::new(), // should be an empty map for unchecked push
302302
stream_type: StreamType::UserDefined,

0 commit comments

Comments
 (0)