Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check memtable against current minute when loading #468

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions server/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
mod filter_optimizer;
mod table_provider;

use chrono::TimeZone;
use chrono::{DateTime, Utc};
use chrono::{TimeZone, Timelike};
use datafusion::arrow::datatypes::Schema;
use datafusion::arrow::record_batch::RecordBatch;
use datafusion::datasource::file_format::parquet::ParquetFormat;
Expand Down Expand Up @@ -128,8 +128,18 @@ impl Query {
) -> Result<(Vec<RecordBatch>, Vec<String>), ExecuteError> {
let ctx = self.create_session_context();
let remote_listing_table = self._remote_query(storage)?;
let memtable =
crate::event::STREAM_WRITERS.recordbatches_cloned(&self.stream_name, &self.schema);

let current_minute = Utc::now()
.with_second(0)
.and_then(|x| x.with_nanosecond(0))
.expect("zeroed value is valid");

let memtable = if self.end > current_minute {
crate::event::STREAM_WRITERS.recordbatches_cloned(&self.stream_name, &self.schema)
} else {
None
};

let table =
QueryTableProvider::try_new(memtable, remote_listing_table, self.schema.clone())?;

Expand Down
Loading