def populate_example_from_sql_spans(sql_spans, example, anonymize):
  """Creates a sequence of output / decoder actions from sql_spans.

  Args:
    sql_spans: List of SqlSpan tuples.
    example: The NLToSQLExample object to add output actions.
    anonymize: Whether to anonymize string/numerical values.

  Raises:
    ParseError: if the SQL query can't be parsed.

  Returns:
    Successful copy.
  """
  successful_copy = True
  for sql_span in sql_spans:
    if sql_span.sql_token:
      _add_generate_action(sql_span.sql_token, example)
    elif sql_span.value_literal:
      successful_copy = _add_value_literal(sql_span.value_literal, example,
                                           anonymize) and successful_copy
    elif sql_span.column:
      _add_column_copy(sql_span.column.table_name, sql_span.column.column_name,
                       example)
    elif sql_span.table_name:
      _add_table_copy(sql_span.table_name, example)
    elif sql_span.nested_statement:
      successful_copy = populate_example_from_sql_spans(
          sql_span.nested_statement, example, anonymize) and successful_copy
    else:
      raise ParseError('Invalid SqlSpan: %s' % sql_span)
  return successful_copy
Creates a sequence of output / decoder actions from sql_spans.

  Args:
    sql_spans: List of SqlSpan tuples.
    example: The NLToSQLExample object to add output actions.
    anonymize: Whether to anonymize string/numerical values.

  Raises:
    ParseError: if the SQL query can't be parsed.

  Returns:
    Successful copy.
  
language/xsp/data_preprocessing/abstract_sql_converters.py