MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / ItemType

Class ItemType

misc/python/materialize/mzexplore/common.py:143–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141
142
143class ItemType(str, Enum):
144 CONNECTION = "connection"
145 FUNCTION = "function"
146 INDEX = "index"
147 MATERIALIZED_VIEW = "materialized-view"
148 SECRET = "secret"
149 SINK = "sink"
150 SOURCE = "source"
151 TABLE = "table"
152 TYPE = "type"
153 VIEW = "view"
154
155 def sql(self) -> str:
156 """Return the SQL string corresponding to this item type."""
157 return self.replace("-", " ").upper()
158
159 def show_create(self, fqname: str) -> str | None:
160 """
161 Return a show create query for an item of the given type identified by
162 the given `fqname` or `None` for item types that are currently not
163 supported.
164 """
165 if self in [
166 ItemType.INDEX,
167 ItemType.MATERIALIZED_VIEW,
168 ItemType.SOURCE,
169 ItemType.TABLE,
170 ItemType.VIEW,
171 ]:
172 return f"SHOW CREATE {self.sql()} {fqname}"
173 else: # unsupported item type
174 return None
175
176
177@dataclass(frozen=True)

Callers 5

defsFunction · 0.90
defsFunction · 0.90
plansFunction · 0.90
arrangement_sizesFunction · 0.90
explain_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected