MCPcopy Create free account
hub / github.com/google-research/language / SQLAction

Class SQLAction

language/xsp/data_preprocessing/sql_utils.py:105–139  ·  view source on GitHub ↗

Describes a single generation action for a SQL query.

Source from the content-addressed store, hash-verified

103
104
105class SQLAction(object):
106 """Describes a single generation action for a SQL query."""
107
108 def __init__(self, symbol=None, entity_copy=None, utterance_copy=None):
109 # Make sure only one of the things are set.
110 assert len([obj for obj in [symbol, entity_copy, utterance_copy] if obj
111 ]) <= 1
112
113 self.symbol = symbol
114 self.entity_copy = entity_copy
115 self.utterance_copy = utterance_copy
116
117 def to_json(self):
118 if self.symbol:
119 return {'symbol': self.symbol}
120 if self.entity_copy:
121 return {'entity_copy': self.entity_copy.to_json()}
122 if self.utterance_copy:
123 return {'utterance_copy': self.utterance_copy.to_json()}
124
125 def from_json(self, dictionary):
126 """Converts from a JSON representation to a SQL action."""
127 # Should only have one key -- any of the above keys.
128 assert len(dictionary) == 1
129 if 'symbol' in dictionary:
130 self.symbol = dictionary['symbol']
131 return self
132
133 if 'entity_copy' in dictionary:
134 self.entity_copy = SchemaEntityCopy().from_json(dictionary['entity_copy'])
135 return self
136
137 if 'utterance_copy' in dictionary:
138 self.utterance_copy = Wordpiece().from_json(dictionary['utterance_copy'])
139 return self
140
141
142class SQLQuery(object):

Callers 12

_add_simple_stepFunction · 0.90
_resolve_referenceFunction · 0.90
_find_directionFunction · 0.90
_add_simple_valueFunction · 0.90
_parse_identifierFunction · 0.90
_add_table_copyFunction · 0.90
_add_column_copyFunction · 0.90
_add_generate_actionFunction · 0.90
_add_value_literalFunction · 0.90
from_jsonMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…