// 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="proto2";

package doris;

message PScalarType {
    // TPrimitiveType, use int32 to avoid redefine Enum
    required int32 type = 1;
    // Only set if type == CHAR or type == VARCHAR
    optional int32 len = 2;
    // Only set for DECIMAL
    optional int32 precision = 3;
    optional int32 scale = 4;
};

// Represents a field in a STRUCT type.
// TODO: Model column stats for struct fields.
message PStructField {
    required string name = 1;
    optional string comment = 2;
};

message PTypeNode {
    // TTypeNodeType(SCALAR, ARRAY, MAP, STRUCT)
    required int32 type = 1; 
    // only set for scalar types
    optional PScalarType scalar_type = 2;
    // only used for structs; has struct_fields.size() corresponding child types
    repeated PStructField struct_fields = 3;
};

// A flattened representation of a tree of column types obtained by depth-first
// traversal. Complex types such as map, array and struct have child types corresponding
// to the map key/value, array item type, and struct fields, respectively.
// For scalar types the list contains only a single node.
// Note: We cannot rename this to TType because it conflicts with Thrift's internal TType
// and the generated Python thrift files will not work.
// Note: TTypeDesc in impala is TColumnType, but we already use TColumnType, so we name this
// to TTypeDesc. In future, we merge these two to one
message PTypeDesc {
    repeated PTypeNode types = 1;
};

message PUniqueId {
    required int64 hi = 1;
    required int64 lo = 2;
};

