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

Function create_namespace

misc/python/materialize/biglake.py:169–186  ·  view source on GitHub ↗

Create the namespace. BigLake doesn't auto-create on first commit. With ``exist_ok`` (the default), a 409 from a namespace that already exists is treated as success, so this is safe to call repeatedly against a fixed long-lived namespace.

(
    token: str, project: str, prefix: str, namespace: str, *, exist_ok: bool = True
)

Source from the content-addressed store, hash-verified

167
168
169def create_namespace(
170 token: str, project: str, prefix: str, namespace: str, *, exist_ok: bool = True
171) -> None:
172 """Create the namespace. BigLake doesn't auto-create on first commit.
173
174 With ``exist_ok`` (the default), a 409 from a namespace that already exists
175 is treated as success, so this is safe to call repeatedly against a fixed
176 long-lived namespace.
177 """
178 req = biglake_request("POST", catalog_url(prefix, "namespaces"), token, project)
179 req.add_header("Content-Type", "application/json")
180 req.data = json.dumps({"namespace": [namespace]}).encode()
181 try:
182 urllib.request.urlopen(req)
183 except urllib.error.HTTPError as e:
184 if exist_ok and e.code == 409:
185 return
186 raise
187
188
189def bootstrap_namespace(service_account: dict, bucket: str, namespace: str) -> str:

Callers 2

workflow_defaultFunction · 0.90
bootstrap_namespaceFunction · 0.85

Calls 3

biglake_requestFunction · 0.85
catalog_urlFunction · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected