// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you 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.



syntax = "proto3";

package spark.spark_expression;

option java_package = "org.apache.comet.serde";

message ListLiteral {
  // Only one of these fields should be populated based on the array type
  repeated bool boolean_values = 1;
  repeated int32 byte_values = 2;
  repeated int32 short_values = 3;
  repeated int32 int_values = 4;
  repeated int64 long_values = 5;
  repeated float float_values = 6;
  repeated double double_values = 7;
  repeated string string_values = 8;
  repeated bytes bytes_values = 9;
  repeated bytes decimal_values = 10;
  repeated ListLiteral list_values = 11;

  repeated bool null_mask = 12;
}

message DataType {
  enum DataTypeId {
    BOOL = 0;
    INT8 = 1;
    INT16 = 2;
    INT32 = 3;
    INT64 = 4;
    FLOAT = 5;
    DOUBLE = 6;
    STRING = 7;
    BYTES = 8;
    TIMESTAMP = 9;
    DECIMAL = 10;
    TIMESTAMP_NTZ = 11;
    DATE = 12;
    NULL = 13;
    LIST = 14;
    MAP = 15;
    STRUCT = 16;
  }
  DataTypeId type_id = 1;

  message DataTypeInfo {
    oneof datatype_struct {
      DecimalInfo decimal = 2;
      ListInfo list = 3;
      MapInfo map = 4;
      StructInfo struct = 5;
    }
  }

  message DecimalInfo {
    int32 precision = 1;
    int32 scale = 2;
  }

  message ListInfo {
    DataType element_type = 1;
    bool contains_null = 2;
  }

  message MapInfo {
    DataType key_type = 1;
    DataType value_type = 2;
    bool value_contains_null = 3;
  }

  message StructInfo {
    repeated string field_names = 1;
    repeated DataType field_datatypes = 2;
    repeated bool field_nullable = 3;
    // Parallel to field_names. Each entry holds Spark field metadata for the
    // corresponding nested field. Currently used to carry parquet.field.id
    // through to the native side. Empty when no fields carry metadata.
    repeated FieldMetadata field_metadata = 4;
  }

  message FieldMetadata {
    map<string, string> metadata = 1;
  }

  DataTypeInfo type_info = 2;
}
