pub struct SqlBatchView { /* private fields */ }Expand description
SQL-defined view updated in batch
Implementations§
Source§impl SqlBatchView
impl SqlBatchView
Sourcepub async fn new(
runtime: Arc<RuntimeEnv>,
view_set_name: Arc<String>,
min_event_time_column: Arc<String>,
max_event_time_column: Arc<String>,
count_src_query: Arc<String>,
extract_query: Arc<String>,
merge_partitions_query: Arc<String>,
lake: Arc<DataLakeConnection>,
view_factory: Arc<ViewFactory>,
session_configurator: Arc<dyn SessionConfigurator>,
update_group: Option<i32>,
max_partition_delta_from_source: TimeDelta,
max_partition_delta_from_merge: TimeDelta,
) -> Result<SqlBatchView, Error>
pub async fn new( runtime: Arc<RuntimeEnv>, view_set_name: Arc<String>, min_event_time_column: Arc<String>, max_event_time_column: Arc<String>, count_src_query: Arc<String>, extract_query: Arc<String>, merge_partitions_query: Arc<String>, lake: Arc<DataLakeConnection>, view_factory: Arc<ViewFactory>, session_configurator: Arc<dyn SessionConfigurator>, update_group: Option<i32>, max_partition_delta_from_source: TimeDelta, max_partition_delta_from_merge: TimeDelta, ) -> Result<SqlBatchView, Error>
§Arguments
runtime- datafusion runtimeview_set_name- name of the tablemin_event_time_column- min(column) should result in the first timestamp in a dataframemax_event_time_column- max(column) should result in the last timestamp in a dataframecount_src_query- used to count the rows of the underlying data to know if a cached partition is up to dateextract_query- used to extract the source data into a cached partitionmerge_partitions_query- used to merge multiple partitions into a single one (and user queries which are one multiple partitions by default)lake- data lakeview_factory- all views accessible to thecount_src_querysession_configurator- configurator for registering custom tables (e.g., JSON files)update_group- tells the daemon which view should be materialized and in what order
Sourcepub fn with_merge_sort_order(
self,
columns: Vec<Arc<String>>,
) -> Result<SqlBatchView, Error>
pub fn with_merge_sort_order( self, columns: Vec<Arc<String>>, ) -> Result<SqlBatchView, Error>
Declares that this view’s partitions are internally sorted, ascending, by columns in
order. columns must be non-empty and every name must exist in this view’s schema.
This is a three-item view-author contract:
- Every declared sort column must appear among the merge query’s
GROUP BYkeys (order withinGROUP BYis irrelevant; extra keys degrade toPartiallySorted, not a blocking sort). - Any enrichment join in the merge query must put the dimension table on the left and the
ordered stream on the right –
CollectLeftbuffers its left (build) input and inherits its output ordering from its right (probe) input, so the natural phrasing(<ordered agg>) a LEFT JOIN dim dreinstates a blocking sort. - The merge query’s aggregates must be composable over already-aggregated rows (e.g.
sum(count), notcount(*); no bareavg– carrysumandcountand divide at read time).log_statsis the in-repo model.
Neither query needs an author-written ORDER BY any more: this builder forwards columns
to both sides, QueryMerger applies the sort to the merge query as a DataFusion
logical-plan node, and the extract path applies it to the extract query the same way (see
sql_partition_spec::plan_sorted_extract) – no SQL text is derived or rewritten on either
side.
Sourcepub fn get_extract_query(&self) -> Arc<String> ⓘ
pub fn get_extract_query(&self) -> Arc<String> ⓘ
The extract query as given to SqlBatchView::new, {begin}/{end} placeholders included.
Sourcepub fn get_merge_partitions_query(&self) -> Arc<String> ⓘ
pub fn get_merge_partitions_query(&self) -> Arc<String> ⓘ
The merge query as given to SqlBatchView::new, {source} placeholder included.
Trait Implementations§
Source§impl Debug for SqlBatchView
impl Debug for SqlBatchView
Source§impl View for SqlBatchView
impl View for SqlBatchView
Source§fn get_view_instance_id(&self) -> Arc<String> ⓘ
fn get_view_instance_id(&self) -> Arc<String> ⓘ
Source§fn make_batch_partition_spec<'life0, 'async_trait>(
&'life0 self,
lakehouse: Arc<LakehouseContext>,
existing_partitions: Arc<PartitionCache>,
insert_range: TimeRange,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn PartitionSpec>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
SqlBatchView: 'async_trait,
fn make_batch_partition_spec<'life0, 'async_trait>(
&'life0 self,
lakehouse: Arc<LakehouseContext>,
existing_partitions: Arc<PartitionCache>,
insert_range: TimeRange,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn PartitionSpec>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
SqlBatchView: 'async_trait,
Source§fn get_file_schema_hash(&self) -> Vec<u8> ⓘ
fn get_file_schema_hash(&self) -> Vec<u8> ⓘ
Source§fn get_file_schema(&self) -> Arc<Schema> ⓘ
fn get_file_schema(&self) -> Arc<Schema> ⓘ
Source§fn jit_update<'life0, 'async_trait>(
&'life0 self,
_lakehouse: Arc<LakehouseContext>,
_query_range: Option<TimeRange>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
SqlBatchView: 'async_trait,
fn jit_update<'life0, 'async_trait>(
&'life0 self,
_lakehouse: Arc<LakehouseContext>,
_query_range: Option<TimeRange>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
SqlBatchView: 'async_trait,
Source§fn make_time_filter(
&self,
begin: DateTime<Utc>,
end: DateTime<Utc>,
) -> Result<Vec<Expr>, Error>
fn make_time_filter( &self, begin: DateTime<Utc>, end: DateTime<Utc>, ) -> Result<Vec<Expr>, Error>
fn get_time_bounds(&self) -> Arc<dyn DataFrameTimeBounds> ⓘ
Source§fn register_table<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 SessionContext,
table: MaterializedView,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
SqlBatchView: 'async_trait,
fn register_table<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 SessionContext,
table: MaterializedView,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
SqlBatchView: 'async_trait,
fn merge_partitions<'life0, 'async_trait>(
&'life0 self,
lakehouse: Arc<LakehouseContext>,
partitions_to_merge: Arc<Vec<Partition>>,
partitions_all_views: Arc<PartitionCache>,
insert_range: TimeRange,
) -> Pin<Box<dyn Future<Output = Result<MergeQueryResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
SqlBatchView: 'async_trait,
Source§fn get_merged_partition_sort_order(
&self,
partitions_to_merge: &[Partition],
) -> Option<Vec<String>>
fn get_merged_partition_sort_order( &self, partitions_to_merge: &[Partition], ) -> Option<Vec<String>>
partitions_to_merge will actually produce, to be
recorded as the resulting partition’s Partition::sort_order (see
merge::create_merged_partition). Read moreSource§fn get_scan_output_ordering(&self) -> ScanOrdering
fn get_scan_output_ordering(&self) -> ScanOrdering
Sort nodes for queries that ORDER BY these columns. Read moreSource§fn get_update_group(&self) -> Option<i32>
fn get_update_group(&self) -> Option<i32>
Source§fn get_max_partition_time_delta(
&self,
strategy: &PartitionCreationStrategy,
) -> TimeDelta
fn get_max_partition_time_delta( &self, strategy: &PartitionCreationStrategy, ) -> TimeDelta
Auto Trait Implementations§
impl !RefUnwindSafe for SqlBatchView
impl !UnwindSafe for SqlBatchView
impl Freeze for SqlBatchView
impl Send for SqlBatchView
impl Sync for SqlBatchView
impl Unpin for SqlBatchView
impl UnsafeUnpin for SqlBatchView
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].