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

package common;

option java_package = "org.apache.drill.common.types";
option java_outer_classname = "TypeProtos";
option optimize_for = SPEED;


enum MinorType {
    LATE = 0;   //  late binding type
    MAP = 1;   //  an empty map column.  Useful for conceptual setup.  Children listed within here

    TINYINT = 3;   //  single byte signed integer
    SMALLINT = 4;   //  two byte signed integer
    INT = 5;   //  four byte signed integer
    BIGINT = 6;   //  eight byte signed integer
    DECIMAL9 = 7;   //  a decimal supporting precision between 1 and 9
    DECIMAL18 = 8;   //  a decimal supporting precision between 10 and 18
    DECIMAL28SPARSE = 9;   //  a decimal supporting precision between 19 and 28
    DECIMAL38SPARSE = 10;   //  a decimal supporting precision between 29 and 38
    MONEY = 11;   //  signed decimal with two digit scale
    DATE = 12;   //  days since 4713bc
    TIME = 13;   //  time in micros before or after 2000/1/1
    TIMETZ = 14;   //  time in micros before or after 2000/1/1 with timezone
    TIMESTAMPTZ = 15;   //  unix epoch time in millis
    TIMESTAMP = 16;   //  TBD
    INTERVAL = 17;   //  TBD
    FLOAT4 = 18;   //  4 byte ieee 754
    FLOAT8 = 19;   //  8 byte ieee 754
    BIT = 20;   //  single bit value (boolean)
    FIXEDCHAR = 21;   //  utf8 fixed length string, padded with spaces
    FIXED16CHAR = 22;
    FIXEDBINARY = 23;   //  fixed length binary, padded with 0 bytes
    VARCHAR = 24;   //  utf8 variable length string
    VAR16CHAR = 25; // utf16 variable length string
    VARBINARY = 26;   //  variable length binary
    UINT1 = 29;   //  unsigned 1 byte integer
    UINT2 = 30;   //  unsigned 2 byte integer
    UINT4 = 31;   //  unsigned 4 byte integer
    UINT8 = 32;   //  unsigned 8 byte integer
    DECIMAL28DENSE = 33; // dense decimal representation, supporting precision between 19 and 28
    DECIMAL38DENSE = 34; // dense decimal representation, supporting precision between 28 and 38
//    PROTO2 = 33;   //  protobuf encoded complex type. (up to 2^16 in length)
//    PROTO4 = 34;   //  protobuf encoded complex type. (up to 2^32 in length)
//    MSGPACK2 = 35;   //  msgpack encoded complex type. (up to 2^16 in length)
//    MSGPACK4 = 36;   //  msgpack encoded complex type. (up to 2^32 in length)
    NULL = 37; // a value of unknown type (e.g. a missing reference).
    INTERVALYEAR = 38; // Interval type specifying YEAR to MONTH
    INTERVALDAY = 39; // Interval type specifying DAY to SECONDS
    LIST = 40;
    GENERIC_OBJECT = 41;
    UNION = 42;
    VARDECIMAL = 43;  // variable width decimal (arbitrary precision)
    DICT = 44;
}

message MajorType {
  optional MinorType minor_type = 1;
  optional DataMode mode = 2;
  optional int32 width = 3;
  optional int32 precision = 4; // used for decimal types or as optional length for fixed size value
  optional int32 scale = 5; // used for decimal types
  optional int32 timeZone = 6; // used by TimeStamp type
  repeated MinorType sub_type = 7; // used by Union type
}

enum DataMode {
  OPTIONAL = 0; // nullable
  REQUIRED = 1; // non-nullable
  REPEATED = 2; // single, repeated-field
}
