//
// 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.
//

syntax = "proto2";

package zetasql;

import "zetasql/public/annotation.proto";
import "zetasql/public/type.proto";

option java_package = "com.google.zetasql";
option java_outer_classname = "SimpleTableProtos";

message SimpleAnonymizationInfoProto {
  // Stores the name path of the 'column' field that identifies the userid
  // column. Required to be set and non-empty.
  repeated string userid_column_name = 1;
}

message SimpleTableProto {
  optional string name = 1;
  optional int64 serialization_id = 2;
  optional bool is_value_table = 3;
  repeated SimpleColumnProto column = 4;
  repeated int32 primary_key_column_index = 9;
  // Alias name of the table when it is added to the parent catalog.  This is
  // only set when the Table is added to the Catalog using a different name
  // than the Table's name.  This name is not part of the SimpleTable, but
  // will be used as the Table's name in the Catalog.
  optional string name_in_catalog = 5;
  optional bool allow_anonymous_column_name = 6;
  optional bool allow_duplicate_column_names = 7;
  // Stores anonymization options and information related to this table.
  // If set, this table is considered to support anonymization semantics and
  // contain private data. If not set, this table is assumed to not be usable
  // in an anonymization context, and not contain private data.
  optional SimpleAnonymizationInfoProto anonymization_info = 8;
  optional string full_name = 10;
}

message ExpressionAttributeProto {
  optional string expression_string = 8;
  enum ExpressionKind {
    DEFAULT = 0;
    GENERATED = 1;
  }
  optional ExpressionKind expression_kind = 9;
}

message SimpleColumnProto {
  optional string name = 1;
  optional TypeProto type = 2;
  optional bool is_pseudo_column = 3;
  optional bool is_writable_column = 4 [default = true];
  optional bool can_update_unwritable_to_default = 6;
  optional AnnotationMapProto annotation_map = 5;
  // TODO: To be deprecated in later versions. Do not add use case
  // for has_default_value. Instead set ExpressionKind in
  // ExpressionAttributeProto
  optional bool has_default_value = 7 [default = false];
  optional ExpressionAttributeProto column_expression = 8;
}
