use datafusion_substrait::substrait;
use prost::bytes::{Buf, BufMut};
use prost::encoding::{DecodeContext, WireType};
use prost::{DecodeError, Message};
#[derive(Clone, PartialEq, Message)]
pub struct MatchRecognizeRel {
#[prost(uint32, optional, tag = "1")]
pub schema_version: Option<u32>,
#[prost(string, repeated, tag = "2")]
pub required_features: Vec<String>,
#[prost(message, repeated, tag = "3")]
pub partition_expressions: Vec<SourceExpression>,
#[prost(message, repeated, tag = "4")]
pub sorts: Vec<SourceSortExpr>,
#[prost(enumeration = "RowsPerMatch", tag = "5")]
pub rows_per_match: i32,
#[prost(message, optional, tag = "6")]
pub after_match_skip: Option<AfterMatchSkip>,
#[prost(message, optional, tag = "7")]
pub pattern: Option<RowPattern>,
#[prost(string, repeated, tag = "8")]
pub symbols: Vec<String>,
#[prost(message, repeated, tag = "9")]
pub definitions: Vec<PatternDefinition>,
#[prost(message, repeated, tag = "10")]
pub measures: Vec<RowPatternMeasure>,
#[prost(message, optional, tag = "11")]
pub output_schema: Option<substrait::proto::NamedStruct>,
#[prost(message, optional, tag = "12")]
pub output_contract: Option<OutputContract>,
#[prost(bool, tag = "13")]
pub semantic_node: bool,
#[prost(bool, tag = "14")]
pub semantic_node_finalizes_one_row: bool,
#[prost(uint32, repeated, tag = "15")]
pub retained_passthrough_input_fields: Vec<u32>,
#[prost(message, repeated, tag = "16")]
pub prepared_output_fields: Vec<PreparedOutputField>,
#[prost(message, repeated, tag = "17")]
pub summary_output_fields: Vec<SummaryOutputField>,
}
#[derive(Clone, PartialEq, Message)]
pub struct PreparedOutputField {
#[prost(uint32, tag = "1")]
pub output_field: u32,
#[prost(message, optional, tag = "2")]
pub expression: Option<substrait::proto::Expression>,
}
#[derive(Clone, PartialEq, Message)]
pub struct SummaryOutputField {
#[prost(uint32, tag = "1")]
pub output_field: u32,
#[prost(string, tag = "2")]
pub function_name: String,
#[prost(message, repeated, tag = "3")]
pub args: Vec<substrait::proto::Expression>,
#[prost(bool, tag = "4")]
pub distinct: bool,
#[prost(message, optional, tag = "5")]
pub filter: Option<substrait::proto::Expression>,
#[prost(message, repeated, tag = "6")]
pub order_by: Vec<SummarySortExpr>,
#[prost(enumeration = "NullTreatment", tag = "7")]
pub null_treatment: i32,
}
#[derive(Clone, PartialEq, Message)]
pub struct SummarySortExpr {
#[prost(message, optional, tag = "1")]
pub expr: Option<substrait::proto::Expression>,
#[prost(enumeration = "SortDirection", tag = "2")]
pub direction: i32,
#[prost(enumeration = "NullOrdering", tag = "3")]
pub null_ordering: i32,
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct SourceExpression {
pub kind: Option<source_expression::Kind>,
}
impl Message for SourceExpression {
fn encode_raw(&self, buf: &mut impl BufMut) {
if let Some(kind) = &self.kind {
kind.encode(buf);
}
}
fn merge_field(
&mut self,
tag: u32,
wire_type: WireType,
buf: &mut impl Buf,
ctx: DecodeContext,
) -> Result<(), DecodeError> {
match tag {
1 | 3..=16 => {
let _scope = super::wire::ExpressionScope::enter()?;
if matches!(tag, 6 | 8 | 11 | 14)
&& wire_type == WireType::LengthDelimited
{
let mut peek = buf.chunk();
if let Ok(len) = prost::encoding::decode_varint(&mut peek)
&& let Ok(len) = usize::try_from(len)
&& len <= peek.len()
{
super::wire::charge_wire_fields(&peek[..len])?;
}
}
source_expression::Kind::merge(
&mut self.kind,
tag,
wire_type,
buf,
DecodeContext::default(),
)
.map_err(|mut error| {
error.push("SourceExpression", "kind");
error
})
}
_ => prost::encoding::skip_field(wire_type, tag, buf, ctx),
}
}
fn encoded_len(&self) -> usize {
self.kind
.as_ref()
.map_or(0, source_expression::Kind::encoded_len)
}
fn clear(&mut self) {
self.kind = None;
}
}
pub mod source_expression {
use datafusion_substrait::substrait;
use prost::Oneof;
#[derive(Clone, PartialEq, Oneof)]
pub enum Kind {
#[prost(message, tag = "1")]
InputExpression(substrait::proto::Expression),
#[prost(message, tag = "3")]
PatternField(super::PatternFieldRef),
#[prost(enumeration = "super::MetadataFunction", tag = "4")]
Metadata(i32),
#[prost(message, tag = "5")]
Navigation(super::NavigationFunction),
#[prost(message, tag = "6")]
Aggregate(super::AggregateCall),
#[prost(message, tag = "7")]
Alias(super::AliasExpr),
#[prost(message, tag = "8")]
ScalarFunction(super::ScalarFunctionCall),
#[prost(message, tag = "9")]
Unary(super::UnaryExpr),
#[prost(message, tag = "10")]
Binary(super::BinaryExpr),
#[prost(message, tag = "11")]
Case(super::CaseExpr),
#[prost(message, tag = "12")]
Predicate(super::PredicateExpr),
#[prost(message, tag = "13")]
Between(super::BetweenExpr),
#[prost(message, tag = "14")]
InList(super::InListExpr),
#[prost(message, tag = "15")]
Cast(super::CastExpr),
#[prost(uint32, tag = "16")]
InputField(u32),
}
}
#[derive(Clone, PartialEq, Message)]
pub struct SourceSortExpr {
#[prost(message, optional, tag = "1")]
pub expr: Option<SourceExpression>,
#[prost(enumeration = "SortDirection", tag = "2")]
pub direction: i32,
#[prost(enumeration = "NullOrdering", tag = "3")]
pub null_ordering: i32,
}
#[derive(Clone, PartialEq, Message)]
pub struct PatternFieldRef {
#[prost(string, tag = "1")]
pub symbol: String,
#[prost(uint32, optional, tag = "3")]
pub input_field: Option<u32>,
}
#[derive(Clone, PartialEq, Message)]
pub struct NavigationFunction {
#[prost(enumeration = "NavigationKind", tag = "1")]
pub kind: i32,
#[prost(message, optional, tag = "2")]
pub expr: Option<Box<SourceExpression>>,
#[prost(message, optional, tag = "3")]
pub offset: Option<Box<SourceExpression>>,
#[prost(message, optional, tag = "4")]
pub default: Option<Box<SourceExpression>>,
}
#[derive(Clone, PartialEq, Message)]
pub struct AggregateCall {
#[prost(string, tag = "1")]
pub name: String,
#[prost(message, repeated, tag = "2")]
pub args: Vec<SourceExpression>,
#[prost(bool, tag = "3")]
pub distinct: bool,
#[prost(message, optional, tag = "4")]
pub filter: Option<Box<SourceExpression>>,
#[prost(message, repeated, tag = "5")]
pub order_by: Vec<SourceSortExpr>,
#[prost(enumeration = "NullTreatment", tag = "6")]
pub null_treatment: i32,
#[prost(string, optional, tag = "7")]
pub wildcard_symbol: Option<String>,
}
#[derive(Clone, PartialEq, Message)]
pub struct AliasExpr {
#[prost(message, optional, tag = "1")]
pub expr: Option<Box<SourceExpression>>,
#[prost(string, tag = "2")]
pub name: String,
}
#[derive(Clone, PartialEq, Message)]
pub struct ScalarFunctionCall {
#[prost(string, tag = "1")]
pub name: String,
#[prost(message, repeated, tag = "2")]
pub args: Vec<SourceExpression>,
}
#[derive(Clone, PartialEq, Message)]
pub struct UnaryExpr {
#[prost(string, tag = "1")]
pub op: String,
#[prost(message, optional, tag = "2")]
pub expr: Option<Box<SourceExpression>>,
}
#[derive(Clone, PartialEq, Message)]
pub struct BinaryExpr {
#[prost(message, optional, tag = "1")]
pub left: Option<Box<SourceExpression>>,
#[prost(enumeration = "BinaryOperator", tag = "2")]
pub op: i32,
#[prost(message, optional, tag = "3")]
pub right: Option<Box<SourceExpression>>,
}
#[derive(Clone, PartialEq, Message)]
pub struct CaseExpr {
#[prost(message, optional, tag = "1")]
pub expr: Option<Box<SourceExpression>>,
#[prost(message, repeated, tag = "2")]
pub when_then: Vec<WhenThen>,
#[prost(message, optional, tag = "3")]
pub else_expr: Option<Box<SourceExpression>>,
}
#[derive(Clone, PartialEq, Message)]
pub struct WhenThen {
#[prost(message, optional, tag = "1")]
pub when: Option<SourceExpression>,
#[prost(message, optional, tag = "2")]
pub then: Option<SourceExpression>,
}
#[derive(Clone, PartialEq, Message)]
pub struct PredicateExpr {
#[prost(enumeration = "PredicateKind", tag = "1")]
pub kind: i32,
#[prost(message, optional, tag = "2")]
pub expr: Option<Box<SourceExpression>>,
}
#[derive(Clone, PartialEq, Message)]
pub struct BetweenExpr {
#[prost(message, optional, tag = "1")]
pub expr: Option<Box<SourceExpression>>,
#[prost(bool, tag = "2")]
pub negated: bool,
#[prost(message, optional, tag = "3")]
pub low: Option<Box<SourceExpression>>,
#[prost(message, optional, tag = "4")]
pub high: Option<Box<SourceExpression>>,
}
#[derive(Clone, PartialEq, Message)]
pub struct InListExpr {
#[prost(message, optional, tag = "1")]
pub expr: Option<Box<SourceExpression>>,
#[prost(message, repeated, tag = "2")]
pub list: Vec<SourceExpression>,
#[prost(bool, tag = "3")]
pub negated: bool,
}
#[derive(Clone, PartialEq, Message)]
pub struct CastExpr {
#[prost(message, optional, tag = "1")]
pub expr: Option<Box<SourceExpression>>,
#[prost(message, optional, tag = "2")]
pub data_type: Option<substrait::proto::Type>,
}
#[derive(Clone, PartialEq, Message)]
pub struct RowPattern {
#[prost(oneof = "row_pattern::Kind", tags = "1, 2, 3, 4, 5, 6, 7")]
pub kind: Option<row_pattern::Kind>,
}
pub mod row_pattern {
use prost::Oneof;
#[derive(Clone, PartialEq, Oneof)]
pub enum Kind {
#[prost(enumeration = "super::PatternSymbol", tag = "1")]
Symbol(i32),
#[prost(message, tag = "2")]
NamedSymbol(super::NamedSymbol),
#[prost(message, tag = "3")]
Exclude(super::NamedSymbol),
#[prost(message, tag = "4")]
Permute(super::SymbolList),
#[prost(message, tag = "5")]
List(super::PatternList),
#[prost(message, tag = "6")]
Group(Box<super::RowPattern>),
#[prost(message, tag = "7")]
Repetition(super::PatternRepetition),
}
}
#[derive(Clone, PartialEq, Message)]
pub struct NamedSymbol {
#[prost(string, tag = "1")]
pub name: String,
}
#[derive(Clone, PartialEq, Message)]
pub struct SymbolList {
#[prost(string, repeated, tag = "1")]
pub names: Vec<String>,
}
#[derive(Clone, PartialEq, Message)]
pub struct PatternList {
#[prost(enumeration = "PatternListKind", tag = "1")]
pub kind: i32,
#[prost(message, repeated, tag = "2")]
pub patterns: Vec<RowPattern>,
}
#[derive(Clone, PartialEq, Message)]
pub struct PatternRepetition {
#[prost(message, optional, tag = "1")]
pub pattern: Option<Box<RowPattern>>,
#[prost(enumeration = "RepetitionQuantifier", tag = "2")]
pub quantifier: i32,
#[prost(uint32, tag = "3")]
pub lower: u32,
#[prost(uint32, tag = "4")]
pub upper: u32,
}
#[derive(Clone, PartialEq, Message)]
pub struct AfterMatchSkip {
#[prost(enumeration = "AfterMatchSkipKind", tag = "1")]
pub kind: i32,
#[prost(string, tag = "2")]
pub symbol: String,
}
#[derive(Clone, PartialEq, Message)]
pub struct PatternDefinition {
#[prost(string, tag = "1")]
pub symbol: String,
#[prost(message, optional, tag = "2")]
pub predicate: Option<SourceExpression>,
}
#[derive(Clone, PartialEq, Message)]
pub struct RowPatternMeasure {
#[prost(string, optional, tag = "1")]
pub name: Option<String>,
#[prost(message, optional, tag = "2")]
pub expression: Option<SourceExpression>,
}
#[derive(Clone, PartialEq, Message)]
pub struct NamedExpression {
#[prost(string, tag = "1")]
pub name: String,
#[prost(message, optional, tag = "2")]
pub expression: Option<SourceExpression>,
}
#[derive(Clone, PartialEq, Message)]
pub struct OutputContract {
#[prost(oneof = "output_contract::Kind", tags = "1, 2")]
pub kind: Option<output_contract::Kind>,
}
pub mod output_contract {
use prost::Oneof;
#[derive(Clone, PartialEq, Oneof)]
pub enum Kind {
#[prost(message, tag = "1")]
Derived(super::DerivedOutput),
#[prost(message, tag = "2")]
Explicit(super::ExplicitOutput),
}
}
#[derive(Clone, PartialEq, Message)]
pub struct DerivedOutput {}
#[derive(Clone, PartialEq, Message)]
pub struct ExplicitOutput {
#[prost(message, repeated, tag = "1")]
pub expressions: Vec<NamedExpression>,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum RowsPerMatch {
Unspecified = 0,
OneRow = 1,
AllRowsShowEmpty = 2,
AllRowsOmitEmpty = 3,
AllRowsWithUnmatched = 4,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum SortDirection {
Unspecified = 0,
Asc = 1,
Desc = 2,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum NullOrdering {
Unspecified = 0,
First = 1,
Last = 2,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum AfterMatchSkipKind {
Unspecified = 0,
PastLastRow = 1,
ToNextRow = 2,
ToFirst = 3,
ToLast = 4,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum MetadataFunction {
Unspecified = 0,
Classifier = 1,
MatchNumber = 2,
MatchSequenceNumber = 3,
Excluded = 4,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum NavigationKind {
Unspecified = 0,
First = 1,
Last = 2,
Prev = 3,
Next = 4,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum NullTreatment {
Unspecified = 0,
RespectNulls = 1,
IgnoreNulls = 2,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum BinaryOperator {
Unspecified = 0,
Eq = 1,
NotEq = 2,
Lt = 3,
LtEq = 4,
Gt = 5,
GtEq = 6,
Plus = 7,
Minus = 8,
Multiply = 9,
Divide = 10,
Modulo = 11,
And = 12,
Or = 13,
IsDistinctFrom = 14,
IsNotDistinctFrom = 15,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum PredicateKind {
Unspecified = 0,
IsNull = 1,
IsNotNull = 2,
IsTrue = 3,
IsFalse = 4,
IsUnknown = 5,
IsNotTrue = 6,
IsNotFalse = 7,
IsNotUnknown = 8,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum PatternSymbol {
Unspecified = 0,
Start = 1,
End = 2,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum PatternListKind {
Unspecified = 0,
Concat = 1,
Alternation = 2,
}
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration,
)]
#[repr(i32)]
pub enum RepetitionQuantifier {
Unspecified = 0,
ZeroOrMore = 1,
OneOrMore = 2,
AtMostOne = 3,
Exactly = 4,
AtLeast = 5,
AtMost = 6,
Range = 7,
ZeroOrMorePossessive = 8,
OneOrMorePossessive = 9,
AtMostOnePossessive = 10,
ExactlyPossessive = 11,
AtLeastPossessive = 12,
AtMostPossessive = 13,
RangePossessive = 14,
ZeroOrMoreReluctant = 15,
OneOrMoreReluctant = 16,
AtMostOneReluctant = 17,
ExactlyReluctant = 18,
AtLeastReluctant = 19,
AtMostReluctant = 20,
RangeReluctant = 21,
}