/*
 * 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 schema;

// Table Schema
message TableSchema {
  // Schema of each column
  repeated ColumnSchema columns = 1;
  // Version of the schema
  uint32 version = 2;
  // Id of timestamp key column
  uint32 timestamp_id = 3;
  // Ids of primary keys
  repeated uint32 primary_key_ids = 4;
}

// Column schema
message ColumnSchema {
  // Column name
  string name = 1;
  // Column type
  DataType data_type = 2;
  // Is the column nullable
  bool is_nullable = 3;
  // Id of the column
  uint32 id = 4;
  // Is the column used as tag
  bool is_tag = 5;
  // Comment of the column
  string comment = 6;
  // Default value expr of the column
  oneof default_value {
    bytes serde_json = 7;
  }
  // Whether the column uses dictionary encoding
  bool is_dictionary = 8;
}

// Data type of column
enum DataType {
  NULL = 0;
  TIMESTAMP = 1;
  DOUBLE = 2;
  VARBINARY = 3;
  STRING = 4;
  UINT64 = 5;
  FLOAT = 6;
  INT64 = 7;
  INT32 = 8;
  INT16 = 9;
  INT8 = 10;
  UINT32 = 11;
  UINT16 = 12;
  UINT8 = 13;
  BOOL = 14;
  DATE = 15;
  TIME = 16;
}

// Projected Schema
message ProjectedSchema {
  TableSchema table_schema = 1;
  Projection projection = 2;
}

message Projection {
  repeated uint64 idx = 1;
}