def get_field_types(field_list, iterations=3):
  assert iterations > 0, "iterations should be a positive integer (not a negative integer or 0)"

  def test_boolean(value):
    if ('false', 'true') not in value.lower():
      raise ValueError(_("%s is not a boolean value") % value)

  def test_timestamp(value):
    if not value:
      raise ValueError()

    if len(value) > 50 or len(value) < 3:
      raise ValueError()

    if value.startswith('[') and value.endswith(']'):
      value = value[1:-1]

    try:
      parse(value)
    except OverflowError:
      raise ValueError()

  def test_int(value):
    if len(bin(int(value))) - 2 > 32:
      raise ValueError()

  def test_string(value):
    if len(smart_str(value).split(' ')) > 4:
      raise ValueError()

  test_fns = [('boolean', test_boolean),
              ('tint', test_int),
              ('tlong', int),
              ('tdouble', float),
              ('tdate', test_timestamp),
              ('string', test_string),
              ('text_general', any)]
  all_field_types = []
  for row in field_list:
    # Try 'iterations' amount of times
    if iterations == 0:
      break

    iterations -= 1

    row_field_types = []
    for field in row:
      field_type_index = None
      for index in range(0, len(test_fns)):
        try:
          test_fns[index][1](field)
          field_type_index = index
          break
        except ValueError:
          pass
      row_field_types.append(field_type_index)
    all_field_types.append(row_field_types)

  # No rows to asses
  if not all_field_types:
    return []

  # Choose based on priority.
  # If a column has largely tint's, but one tlong, then the type should be tlong.
  final_field_types = all_field_types[0]
  for row_field_types in all_field_types:
    for index in range(0, len(row_field_types)):
      if row_field_types[index] > final_field_types[index]:
        final_field_types[index] = row_field_types[index]

  return [test_fns[index][0] for index in final_field_types]
dataset/ETHPy150Open cloudera/hue/desktop/libs/indexer/src/indexer/utils.py/get_field_types/swapped operands of `not in`