#
# Autogenerated by Thrift Compiler (0.11.0)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
#  options string: py
#

from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException
from thrift.protocol.TProtocol import TProtocolException
from thrift.TRecursive import fix_spec

import sys

from thrift.transport import TTransport
all_structs = []


class DataType(object):
    NULL = 0
    BOOLEAN = 1
    TINYINT = 2
    SMALLINT = 3
    INTEGER = 4
    BIGINT = 5
    DECIMAL = 6
    FLOAT = 7
    DATE = 8
    TIME = 9
    TIMESTAMP = 10
    INTERVAL = 11
    VARCHAR = 12
    VARBINARY = 13

    _VALUES_TO_NAMES = {
        0: "NULL",
        1: "BOOLEAN",
        2: "TINYINT",
        3: "SMALLINT",
        4: "INTEGER",
        5: "BIGINT",
        6: "DECIMAL",
        7: "FLOAT",
        8: "DATE",
        9: "TIME",
        10: "TIMESTAMP",
        11: "INTERVAL",
        12: "VARCHAR",
        13: "VARBINARY",
    }

    _NAMES_TO_VALUES = {
        "NULL": 0,
        "BOOLEAN": 1,
        "TINYINT": 2,
        "SMALLINT": 3,
        "INTEGER": 4,
        "BIGINT": 5,
        "DECIMAL": 6,
        "FLOAT": 7,
        "DATE": 8,
        "TIME": 9,
        "TIMESTAMP": 10,
        "INTERVAL": 11,
        "VARCHAR": 12,
        "VARBINARY": 13,
    }


class ColumnMetadata(object):
    """
    Attributes:
     - columnName
     - columnType
     - precision
     - scale
     - isNullable
     - charsetName
     - collationName
     - isAutoIncrement
    """


    def __init__(self, columnName=None, columnType=None, precision=None, scale=None, isNullable=None, charsetName=None, collationName=None, isAutoIncrement=None,):
        self.columnName = columnName
        self.columnType = columnType
        self.precision = precision
        self.scale = scale
        self.isNullable = isNullable
        self.charsetName = charsetName
        self.collationName = collationName
        self.isAutoIncrement = isAutoIncrement

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.STRING:
                    self.columnName = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.I32:
                    self.columnType = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.I32:
                    self.precision = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.I32:
                    self.scale = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 5:
                if ftype == TType.BOOL:
                    self.isNullable = iprot.readBool()
                else:
                    iprot.skip(ftype)
            elif fid == 6:
                if ftype == TType.STRING:
                    self.charsetName = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 7:
                if ftype == TType.STRING:
                    self.collationName = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 8:
                if ftype == TType.BOOL:
                    self.isAutoIncrement = iprot.readBool()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('ColumnMetadata')
        if self.columnName is not None:
            oprot.writeFieldBegin('columnName', TType.STRING, 1)
            oprot.writeString(self.columnName.encode('utf-8') if sys.version_info[0] == 2 else self.columnName)
            oprot.writeFieldEnd()
        if self.columnType is not None:
            oprot.writeFieldBegin('columnType', TType.I32, 2)
            oprot.writeI32(self.columnType)
            oprot.writeFieldEnd()
        if self.precision is not None:
            oprot.writeFieldBegin('precision', TType.I32, 3)
            oprot.writeI32(self.precision)
            oprot.writeFieldEnd()
        if self.scale is not None:
            oprot.writeFieldBegin('scale', TType.I32, 4)
            oprot.writeI32(self.scale)
            oprot.writeFieldEnd()
        if self.isNullable is not None:
            oprot.writeFieldBegin('isNullable', TType.BOOL, 5)
            oprot.writeBool(self.isNullable)
            oprot.writeFieldEnd()
        if self.charsetName is not None:
            oprot.writeFieldBegin('charsetName', TType.STRING, 6)
            oprot.writeString(self.charsetName.encode('utf-8') if sys.version_info[0] == 2 else self.charsetName)
            oprot.writeFieldEnd()
        if self.collationName is not None:
            oprot.writeFieldBegin('collationName', TType.STRING, 7)
            oprot.writeString(self.collationName.encode('utf-8') if sys.version_info[0] == 2 else self.collationName)
            oprot.writeFieldEnd()
        if self.isAutoIncrement is not None:
            oprot.writeFieldBegin('isAutoIncrement', TType.BOOL, 8)
            oprot.writeBool(self.isAutoIncrement)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.columnName is None:
            raise TProtocolException(message='Required field columnName is unset!')
        if self.columnType is None:
            raise TProtocolException(message='Required field columnType is unset!')
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)
all_structs.append(ColumnMetadata)
ColumnMetadata.thrift_spec = (
    None,  # 0
    (1, TType.STRING, 'columnName', 'UTF8', None, ),  # 1
    (2, TType.I32, 'columnType', None, None, ),  # 2
    (3, TType.I32, 'precision', None, None, ),  # 3
    (4, TType.I32, 'scale', None, None, ),  # 4
    (5, TType.BOOL, 'isNullable', None, None, ),  # 5
    (6, TType.STRING, 'charsetName', 'UTF8', None, ),  # 6
    (7, TType.STRING, 'collationName', 'UTF8', None, ),  # 7
    (8, TType.BOOL, 'isAutoIncrement', None, None, ),  # 8
)
fix_spec(all_structs)
del all_structs
