def _has_valid_shape(table):
  """Returns true if table has a rectangular shape."""
  if not table.columns:
    return False
  if not table.rows:
    return False
  num_columns = len(table.columns)
  for row in table.rows:
    if len(row.cells) != num_columns:
      return False
  return True