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

Function plans

misc/python/materialize/mzexplore/extract.py:121–338  ·  view source on GitHub ↗

Extract EXPLAIN plans for selected catalog items. Processes only items that match the ILIKE pattern defined by the parameter triple (DATABASE, SCHEMA, NAME).

(
    target: Path,
    database: str,
    schema: str,
    name: str,
    db_port: int,
    db_host: str,
    db_user: str,
    db_pass: str | None,
    db_require_ssl: bool,
    explainee_type: ExplaineeType,
    explain_options: list[ExplainOption],
    explain_stages: set[ExplainStage],
    explain_format: ExplainFormat,
    suffix: str | None = None,
    system: bool = False,
)

Source from the content-addressed store, hash-verified

119
120
121def plans(
122 target: Path,
123 database: str,
124 schema: str,
125 name: str,
126 db_port: int,
127 db_host: str,
128 db_user: str,
129 db_pass: str | None,
130 db_require_ssl: bool,
131 explainee_type: ExplaineeType,
132 explain_options: list[ExplainOption],
133 explain_stages: set[ExplainStage],
134 explain_format: ExplainFormat,
135 suffix: str | None = None,
136 system: bool = False,
137) -> None:
138 """
139 Extract EXPLAIN plans for selected catalog items.
140
141 Processes only items that match the ILIKE pattern defined by the parameter
142 triple (DATABASE, SCHEMA, NAME).
143 """
144
145 # Click doesn't deduplicate, so we need to convert explain_stages (which is
146 # actually a list) into a set explicitly.
147 explain_stages = set(explain_stages)
148
149 if not explain_options:
150 # We should have at least arity for good measure.
151 explain_options = [ExplainOption(key="arity")]
152
153 with closing(
154 sql.Database(
155 port=db_port,
156 host=db_host,
157 user=db_user,
158 database=None,
159 password=db_pass,
160 require_ssl=db_require_ssl,
161 )
162 ) as db:
163 for item in db.catalog_items(database, schema, name, system):
164 item_database = sql.identifier(item["database"])
165 item_schema = sql.identifier(item["schema"])
166 item_name = sql.identifier(item["name"])
167 if item["database"] == "mz": # don't prepend pseudo-database `mz`
168 fqname = f"{item_schema}.{item_name}"
169 else:
170 fqname = f"{item_database}.{item_schema}.{item_name}"
171
172 try:
173 item_type = ItemType(item["type"])
174 except ValueError:
175 warn(f"Unsupported item type `{item['type']}` for {fqname}")
176 continue
177
178 plans: dict[ExplainFile, str] = {}

Callers

nothing calls this directly

Calls 15

skipMethod · 0.95
sqlMethod · 0.95
skipMethod · 0.95
pathMethod · 0.95
folderMethod · 0.95
pathMethod · 0.95
ExplainOptionClass · 0.90
ItemTypeClass · 0.90
warnFunction · 0.90
ExplainFileClass · 0.90
infoFunction · 0.90
CreateFileClass · 0.90

Tested by

no test coverage detected