//
// Copyright 2019 Google LLC
//
// 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.
//

// LINT: LEGACY_NAMES
syntax = "proto2";

package zetasql;

import "zetasql/public/simple_value.proto";

option cc_enable_arenas = true;
option java_package = "com.google.zetasql";
option java_outer_classname = "ZetaSQLAnnotation";

// Map entry from AnnotationSpec ID to AnnotationValue.
message AnnotationProto {
  // Key for the map entry.
  optional int64 id = 1;

  // Value of the map entry.
  optional SimpleValueProto value = 2;
}

// This represents the serialized form of the annotation map for
// zetasql::AnnotatedType.
message AnnotationMapProto {
  // Indicates that an element of array or a field of struct is null. In
  // ArrayAnnotationMap and StructAnnotationMap class, a null element/field
  // indicates that the AnnotationMap for the element/field (and all its
  // children if applicable) is empty.
  // <is_null> can only be true for struct field or array element, or an error
  // is throw during deserialization. If <is_null> is true, the rest of this
  // proto is ignored.
  optional bool is_null = 4;

  repeated AnnotationProto annotations = 1;

  // If AnnotatedType is a complex type, then exactly one of the two
  // fields will be populated.
  optional AnnotationMapProto array_element = 2;
  repeated AnnotationMapProto struct_fields = 3;
}
