MCPcopy Create free account
hub / github.com/awslabs/gap-text2sql / Schema

Class Schema

rat-sql-gap/seq2struct/datasets/spider_lib/process_sql.py:48–76  ·  view source on GitHub ↗

Simple schema which maps table&column to a unique identifier

Source from the content-addressed store, hash-verified

46
47
48class Schema:
49 """
50 Simple schema which maps table&column to a unique identifier
51 """
52 def __init__(self, schema):
53 self._schema = schema
54 self._idMap = self._map(self._schema)
55
56 @property
57 def schema(self):
58 return self._schema
59
60 @property
61 def idMap(self):
62 return self._idMap
63
64 def _map(self, schema):
65 idMap = {'*': "__all__"}
66 id = 1
67 for key, vals in schema.items():
68 for val in vals:
69 idMap[key.lower() + "." + val.lower()] = "__" + key.lower() + "." + val.lower() + "__"
70 id += 1
71
72 for key in schema:
73 idMap[key.lower()] = "__" + key.lower() + "__"
74 id += 1
75
76 return idMap
77
78
79def get_schema(db):

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected