if_is_literal(item):
prev_len = len(example.gold_sql_query.actions)
_add_simple_value(item, example, anonymize_values)iflen(example.gold_sql_query.actions)== prev_len:
raise ValueError(
"Gold query did not change length when adding simple value!")continue
After Change
def _parse_identifier(sql, example, anonymize_values):
Parse the part relative to an Identifier in the SQL query.
successful_copy = Truefor item in sql:
if item.ttype == sqlparse.tokens.Text.Whitespace:
continueif_is_identifier(item):
successful_copy = _parse_identifier(item, example,
anonymize_values) and successful_copycontinueif_is_order(item):
_add_simple_step(item, example)continueif(_is_table_alias(item)or(_is_punctuation(item) and item.value == ".")):
_add_simple_step(item, example)
continueif_is_keyword(item) and item.value in("as",):
_add_simple_step(item, example)continueif_is_name(item):
entity = _find_simple_entity(item.value, example)
if entity is not None:
schema_copy_action = None
ifisinstance(entity, DatabaseTable):
schema_copy_action = SchemaEntityCopy(copied_table=entity)
elif isinstance(entity, TableColumn):
schema_copy_action = SchemaEntityCopy(copied_column=entity)
else:
raise ValueError("Type of entity is unexpected: " + str(type(entity)))
copy_action = SQLAction(entity_copy=schema_copy_action)
example.gold_sql_query.actions.append(copy_action)
else:
try:
_resolve_reference(item, example)
except AttributeError as e:
// Generally this means the reference wasn"t found i.e., in WikiSQL, a// value didn"t have quotes, so just add it as a value
print(e)
successful_copy = _add_simple_value(
item, example, anonymize_values) and successful_copy
continueif_is_literal(item):
prev_len = len(example.gold_sql_query.actions)
successful_copy = _add_simple_value(item, example,
anonymize_values) and successful_copyiflen(example.gold_sql_query.actions)== prev_len:
raise ValueError(
"Gold query did not change length when adding simple value!")continue_debug_state(item, example)
raise ParseError("Incomplete _parse_identifier")return successful_copy
def _parse_operation(sql, example, anonymize_values):
Parse the part relative to an Operation in the SQL query.