pub struct StreamSchema {
pub include_key: bool,
pub key_column_name: String,
pub include_id: bool,
pub id_column_name: String,
pub include_timestamp: bool,
pub timestamp_column_name: String,
pub include_sequence: bool,
pub sequence_column_name: String,
pub fields: Vec<String>,
pub include_row_index: bool,
pub row_index_column_name: String,
}Expand description
Schema configuration for Redis Stream scanning.
Defines output columns when scanning Redis Streams. Each stream entry becomes a row in the output DataFrame.
§Example
use polars_redis::StreamSchema;
let schema = StreamSchema::new(vec![
"user_id".to_string(),
"action".to_string(),
"payload".to_string(),
])
.with_key(true)
.with_id(true)
.with_timestamp(true);§Output Schema
_key(optional): The Redis stream key_id(optional): The entry ID (e.g., “1234567890123-0”)_timestamp(optional): Timestamp extracted from entry ID (Int64 ms)_sequence(optional): Sequence number from entry ID- User-defined fields extracted from entry data
_index(optional): Global row number
Fields§
§include_key: boolWhether to include the Redis key as a column.
key_column_name: StringName of the key column.
include_id: boolWhether to include the entry ID as a column.
id_column_name: StringName of the entry ID column.
include_timestamp: boolWhether to include the timestamp as a column.
timestamp_column_name: StringName of the timestamp column.
include_sequence: boolWhether to include the sequence number as a column.
sequence_column_name: StringName of the sequence column.
fields: Vec<String>Field names to extract from entries.
include_row_index: boolWhether to include a global row index column.
row_index_column_name: StringName of the row index column.
Implementations§
Source§impl StreamSchema
impl StreamSchema
Sourcepub fn with_fields(fields: Vec<String>) -> Self
pub fn with_fields(fields: Vec<String>) -> Self
Create a new StreamSchema with the specified fields.
Sourcepub fn with_key_column_name(self, name: &str) -> Self
pub fn with_key_column_name(self, name: &str) -> Self
Set the key column name.
Sourcepub fn with_id_column_name(self, name: &str) -> Self
pub fn with_id_column_name(self, name: &str) -> Self
Set the entry ID column name.
Sourcepub fn with_timestamp(self, include: bool) -> Self
pub fn with_timestamp(self, include: bool) -> Self
Set whether to include the timestamp column.
Sourcepub fn with_timestamp_column_name(self, name: &str) -> Self
pub fn with_timestamp_column_name(self, name: &str) -> Self
Set the timestamp column name.
Sourcepub fn with_sequence(self, include: bool) -> Self
pub fn with_sequence(self, include: bool) -> Self
Set whether to include the sequence column.
Sourcepub fn with_sequence_column_name(self, name: &str) -> Self
pub fn with_sequence_column_name(self, name: &str) -> Self
Set the sequence column name.
Sourcepub fn set_fields(self, fields: Vec<String>) -> Self
pub fn set_fields(self, fields: Vec<String>) -> Self
Set the fields to extract from entries.
Sourcepub fn with_row_index(self, include: bool) -> Self
pub fn with_row_index(self, include: bool) -> Self
Set whether to include a global row index column.
Sourcepub fn with_row_index_column_name(self, name: &str) -> Self
pub fn with_row_index_column_name(self, name: &str) -> Self
Set the row index column name.
Sourcepub fn to_arrow_schema(&self) -> Schema
pub fn to_arrow_schema(&self) -> Schema
Build the Arrow schema for this configuration.
Trait Implementations§
Source§impl Clone for StreamSchema
impl Clone for StreamSchema
Source§fn clone(&self) -> StreamSchema
fn clone(&self) -> StreamSchema
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StreamSchema
impl Debug for StreamSchema
Auto Trait Implementations§
impl Freeze for StreamSchema
impl RefUnwindSafe for StreamSchema
impl Send for StreamSchema
impl Sync for StreamSchema
impl Unpin for StreamSchema
impl UnwindSafe for StreamSchema
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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