// Copyright (C) 2025 Rivos Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Autogenerated by the ProtoZero Rust compiler plugin.
// Invoked by contrib/rust-sdk/tools/gen_rust_protos
// DO NOT EDIT.

use crate::pb_enum;
use crate::pb_msg;

pb_enum!(ExperimentalFilterGroupOperator {
    UNSPECIFIED: 0,
    AND: 1,
    OR: 2,
});

pb_enum!(OrderByDirection {
    UNSPECIFIED: 0,
    ASC: 1,
    DESC: 2,
});

pb_enum!(AggregateOp {
    UNSPECIFIED: 0,
    COUNT: 1,
    SUM: 2,
    MIN: 3,
    MAX: 4,
    MEAN: 5,
    MEDIAN: 6,
    DURATION_WEIGHTED_MEAN: 7,
    COUNT_DISTINCT: 9,
    PERCENTILE: 8,
    CUSTOM: 10,
});

pb_enum!(FilterOperator {
    UNKNOWN: 0,
    EQUAL: 1,
    NOT_EQUAL: 2,
    LESS_THAN: 3,
    LESS_THAN_EQUAL: 4,
    GREATER_THAN: 5,
    GREATER_THAN_EQUAL: 6,
    IS_NULL: 8,
    IS_NOT_NULL: 9,
    GLOB: 7,
});

pb_enum!(ExperimentalJoinType { INNER: 0, LEFT: 1 });

pb_enum!(ExperimentalTimeRangeMode {
    STATIC: 0,
    DYNAMIC: 1,
});

pb_msg!(PerfettoSqlStructuredQuery {
    id: String, primitive, 1,
    referenced_modules: String, primitive, 11,
    table: PerfettoSqlStructuredQueryTable, msg, 2,
    sql: PerfettoSqlStructuredQuerySql, msg, 3,
    simple_slices: PerfettoSqlStructuredQuerySimpleSlices, msg, 4,
    inner_query: PerfettoSqlStructuredQuery, msg, 5,
    inner_query_id: String, primitive, 6,
    interval_intersect: PerfettoSqlStructuredQueryIntervalIntersect, msg, 7,
    experimental_join: PerfettoSqlStructuredQueryExperimentalJoin, msg, 100,
    experimental_union: PerfettoSqlStructuredQueryExperimentalUnion, msg, 101,
    experimental_add_columns: PerfettoSqlStructuredQueryExperimentalAddColumns, msg, 102,
    experimental_create_slices: PerfettoSqlStructuredQueryExperimentalCreateSlices, msg, 104,
    experimental_time_range: PerfettoSqlStructuredQueryExperimentalTimeRange, msg, 105,
    experimental_filter_to_intervals: PerfettoSqlStructuredQueryExperimentalFilterToIntervals, msg, 106,
    experimental_counter_intervals: PerfettoSqlStructuredQueryExperimentalCounterIntervals, msg, 107,
    experimental_filter_in: PerfettoSqlStructuredQueryExperimentalFilterIn, msg, 108,
    filters: PerfettoSqlStructuredQueryFilter, msg, 8,
    group_by: PerfettoSqlStructuredQueryGroupBy, msg, 9,
    select_columns: PerfettoSqlStructuredQuerySelectColumn, msg, 10,
    order_by: PerfettoSqlStructuredQueryOrderBy, msg, 14,
    limit: i64, primitive, 12,
    offset: i64, primitive, 13,
    experimental_filter_group: PerfettoSqlStructuredQueryExperimentalFilterGroup, msg, 103,
});

pb_msg!(PerfettoSqlStructuredQueryExperimentalFilterGroup {
    op: ExperimentalFilterGroupOperator, enum, 1,
    filters: PerfettoSqlStructuredQueryFilter, msg, 2,
    groups: PerfettoSqlStructuredQueryExperimentalFilterGroup, msg, 3,
    sql_expressions: String, primitive, 4,
});

pb_msg!(PerfettoSqlStructuredQueryOrderBy {
    ordering_specs: PerfettoSqlStructuredQueryOrderByOrderingSpec, msg, 1,
});

pb_msg!(PerfettoSqlStructuredQueryOrderByOrderingSpec {
    column_name: String, primitive, 1,
    direction: OrderByDirection, enum, 2,
});

pb_msg!(PerfettoSqlStructuredQuerySelectColumn {
    column_name_or_expression: String, primitive, 3,
    alias: String, primitive, 2,
    column_name: String, primitive, 1,
});

pb_msg!(PerfettoSqlStructuredQueryGroupBy {
    column_names: String, primitive, 1,
    aggregates: PerfettoSqlStructuredQueryGroupByAggregate, msg, 2,
});

pb_msg!(PerfettoSqlStructuredQueryGroupByAggregate {
    column_name: String, primitive, 1,
    op: AggregateOp, enum, 2,
    result_column_name: String, primitive, 3,
    percentile: f64, primitive, 4,
    custom_sql_expression: String, primitive, 5,
});

pb_msg!(PerfettoSqlStructuredQueryFilter {
    column_name: String, primitive, 1,
    op: FilterOperator, enum, 2,
    string_rhs: String, primitive, 3,
    double_rhs: f64, primitive, 4,
    int64_rhs: i64, primitive, 5,
});

pb_msg!(PerfettoSqlStructuredQueryExperimentalFilterIn {
    base: PerfettoSqlStructuredQuery, msg, 1,
    match_values: PerfettoSqlStructuredQuery, msg, 2,
    base_column: String, primitive, 3,
    match_column: String, primitive, 4,
});

pb_msg!(PerfettoSqlStructuredQueryExperimentalCounterIntervals {
    input_query: PerfettoSqlStructuredQuery, msg, 1,
});

pb_msg!(PerfettoSqlStructuredQueryExperimentalCreateSlices {
    starts_query: PerfettoSqlStructuredQuery, msg, 1,
    ends_query: PerfettoSqlStructuredQuery, msg, 2,
    starts_ts_column: String, primitive, 3,
    ends_ts_column: String, primitive, 4,
});

pb_msg!(PerfettoSqlStructuredQueryExperimentalAddColumns {
    core_query: PerfettoSqlStructuredQuery, msg, 1,
    input_query: PerfettoSqlStructuredQuery, msg, 2,
    input_columns: PerfettoSqlStructuredQuerySelectColumn, msg, 3,
    equality_columns: PerfettoSqlStructuredQueryExperimentalJoinEqualityColumns, msg, 4,
    freeform_condition: PerfettoSqlStructuredQueryExperimentalJoinFreeformCondition, msg, 5,
});

pb_msg!(PerfettoSqlStructuredQueryExperimentalUnion {
    queries: PerfettoSqlStructuredQuery, msg, 1,
    use_union_all: bool, primitive, 2,
});

pb_msg!(PerfettoSqlStructuredQueryExperimentalJoin {
    type: ExperimentalJoinType, enum, 1,
    left_query: PerfettoSqlStructuredQuery, msg, 2,
    right_query: PerfettoSqlStructuredQuery, msg, 3,
    equality_columns: PerfettoSqlStructuredQueryExperimentalJoinEqualityColumns, msg, 4,
    freeform_condition: PerfettoSqlStructuredQueryExperimentalJoinFreeformCondition, msg, 5,
});

pb_msg!(PerfettoSqlStructuredQueryExperimentalJoinFreeformCondition {
    left_query_alias: String, primitive, 1,
    right_query_alias: String, primitive, 2,
    sql_expression: String, primitive, 3,
});

pb_msg!(PerfettoSqlStructuredQueryExperimentalJoinEqualityColumns {
    left_column: String, primitive, 1,
    right_column: String, primitive, 2,
});

pb_msg!(PerfettoSqlStructuredQueryExperimentalTimeRange {
    mode: ExperimentalTimeRangeMode, enum, 1,
    ts: i64, primitive, 2,
    dur: i64, primitive, 3,
});

pb_msg!(PerfettoSqlStructuredQueryExperimentalFilterToIntervals {
    base: PerfettoSqlStructuredQuery, msg, 1,
    intervals: PerfettoSqlStructuredQuery, msg, 2,
    partition_columns: String, primitive, 3,
    clip_to_intervals: bool, primitive, 4,
    select_columns: String, primitive, 5,
});

pb_msg!(PerfettoSqlStructuredQueryIntervalIntersect {
    base: PerfettoSqlStructuredQuery, msg, 1,
    interval_intersect: PerfettoSqlStructuredQuery, msg, 2,
    partition_columns: String, primitive, 3,
});

pb_msg!(PerfettoSqlStructuredQuerySql {
    sql: String, primitive, 1,
    column_names: String, primitive, 2,
    dependencies: PerfettoSqlStructuredQuerySqlDependency, msg, 4,
    preamble: String, primitive, 3,
});

pb_msg!(PerfettoSqlStructuredQuerySqlDependency {
    alias: String, primitive, 1,
    query: PerfettoSqlStructuredQuery, msg, 2,
});

pb_msg!(PerfettoSqlStructuredQuerySimpleSlices {
    slice_name_glob: String, primitive, 1,
    thread_name_glob: String, primitive, 2,
    process_name_glob: String, primitive, 3,
    track_name_glob: String, primitive, 4,
});

pb_msg!(PerfettoSqlStructuredQueryTable {
    table_name: String, primitive, 1,
    column_names: String, primitive, 3,
    module_name: String, primitive, 2,
});
