def visit_replace(self, tokens):
    table_spec = self._GetDescendants(tokens, 'table_spec')
    try:
      table = self._db_schema.FindTableFromSpec(table_spec[0])
    except schema.UnknownNameException:
      self.AddError(tokens, 'Unknown table')
      return
    db_columns = set(str(c) for c in table.GetColumns())

    column_specs = self._GetDescendants(tokens, 'column_spec')
    table_name = table_spec[0]['table'][0]
    query_columns = set(spec['column'][0].lower() for spec in column_specs
                        if not spec.get('table')
                        or spec['table'][0] in (None, table_name))
    if query_columns:
      if db_columns != query_columns:
        self.AddError(tokens,
                      'REPLACE doesn\'t specify all columns: %s vs. %s' %
                      (query_columns, db_columns))
    else:
      # No column names, we have to check value counts.
      value_lists = self._GetDescendants(tokens, 'vals')
      for value_list in value_lists:
        if len(value_list) != len(db_columns):
          self.AddError(tokens,
                        'REPLACE value count doesn\'t match DB column count: '
                        '%d vs. %d' % (len(value_list), len(db_columns)))
dataset/ETHPy150Open google/mysql-tools/parser_lib/validator.py/ReplaceChecker.visit_replace/original