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

Class DatabaseTable

language/xsp/data_preprocessing/schema_utils.py:75–110  ·  view source on GitHub ↗

Contains information about a table in a database.

Source from the content-addressed store, hash-verified

73
74
75class DatabaseTable(object):
76 """Contains information about a table in a database."""
77
78 def __init__(self):
79 self.original_table_name = None
80 self.table_name_wordpieces = list()
81 self.table_columns = list()
82 self.matches_to_utterance = None
83
84 def to_json(self):
85 return {
86 'original_table_name': self.original_table_name,
87 'table_name_wordpieces': [
88 wordpiece.to_json() for wordpiece in self.table_name_wordpieces
89 ],
90 'table_columns': [column.to_json() for column in self.table_columns],
91 'matches_to_utterance': self.matches_to_utterance
92 }
93
94 def from_json(self, dictionary):
95 """Converts from a JSON dictionary to a DatabaseTable object."""
96 self.original_table_name = dictionary['original_table_name']
97 self.table_name_wordpieces = [
98 Wordpiece().from_json(wordpiece)
99 for wordpiece in dictionary['table_name_wordpieces']
100 ]
101 self.table_columns = [
102 TableColumn().from_json(column)
103 for column in dictionary['table_columns']
104 ]
105 self.matches_to_utterance = dictionary['matches_to_utterance']
106
107 return self
108
109 def __str__(self):
110 return json.dumps(self.to_json())
111
112
113def column_is_primary_key(column):

Callers 3

from_jsonMethod · 0.90
from_jsonMethod · 0.90
process_tableFunction · 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…