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

Class TableColumn

language/xsp/data_preprocessing/schema_utils.py:29–72  ·  view source on GitHub ↗

Contains information about column in a database table.

Source from the content-addressed store, hash-verified

27
28
29class TableColumn(object):
30 """Contains information about column in a database table."""
31
32 def __init__(self):
33 self.original_column_name = None
34 self.column_name_wordpieces = list()
35 self.column_type = None
36 self.table_name = None
37 self.is_foreign_key = None
38 self.matches_to_utterance = None
39
40 def to_json(self):
41 assert self.column_type in ACCEPTABLE_COL_TYPES, (
42 ('Column type not '
43 'recognized: %r; name: %r') %
44 (self.column_type, self.original_column_name))
45 return {
46 'original_column_name': self.original_column_name,
47 'column_name_wordpieces': [
48 wordpiece.to_json() for wordpiece in self.column_name_wordpieces
49 ],
50 'column_type': self.column_type,
51 'table_name': self.table_name,
52 'is_foreign_key': self.is_foreign_key,
53 'matches_to_utterance': self.matches_to_utterance
54 }
55
56 def from_json(self, dictionary):
57 """Sets the properties of the column from a dictionary representation."""
58 self.original_column_name = dictionary['original_column_name']
59 self.column_name_wordpieces = [
60 Wordpiece().from_json(wordpiece)
61 for wordpiece in dictionary['column_name_wordpieces']
62 ]
63 self.column_type = dictionary['column_type']
64 self.table_name = dictionary['table_name']
65 self.is_foreign_key = dictionary['is_foreign_key']
66 self.matches_to_utterance = dictionary['matches_to_utterance']
67 assert self.column_type in ACCEPTABLE_COL_TYPES, (
68 ('Column type not '
69 'recognized: %r; name: %r') %
70 (self.column_type, self.original_column_name))
71
72 return self
73
74
75class DatabaseTable(object):

Callers 3

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