Query Text Registry
Per-schema query-text registry.
Maps query_text_id values to their SQL strings on a per-schema basis.
The mapping for each schema is loaded lazily on first access and kept in a
module-level cache so subsequent lookups are O(1).
Storage layout
{data_root}/__query_texts/{schema_name}/query_texts.parquet
The Parquet file must contain at least two columns:
query_text_id(str) – the opaque key used in the workload schema.query_text(str) – the SQL text for that key.
Usage
from autoslo.workload_definition.query_text_registry import QueryTextRegistry sql = QueryTextRegistry.get("ext_tpcds1000", "42_001")
To populate the registry for testing or new schemas without writing a
Parquet file, use :meth:QueryTextRegistry.register:
QueryTextRegistry.register("my_schema", {"q1": "SELECT 1", "q2": "SELECT 2"})
QueryTextRegistry
Lazily-loaded, per-schema registry mapping query_text_id to SQL.
Source code in src/autoslo/workload_definition/query_text_registry.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
get(query_text_id)
Return the SQL text for query_text_id within this registry's schema.
Returns None if the id is not found.
Parameters
query_text_id: The opaque key for the desired query text.
Returns
str or None
The SQL string, or None if not found.
Source code in src/autoslo/workload_definition/query_text_registry.py
get_from_schema(schema_name, query_text_id)
classmethod
Return the SQL text for query_text_id within schema_name.
Loads the schema's registry file on first access. Returns None
if the schema has no registered texts or the id is not found.
Parameters
schema_name:
The schema identifier (e.g. "ext_tpcds1000").
query_text_id:
The opaque key for the desired query text.
Returns
str or None
The SQL string, or None if not found.
Source code in src/autoslo/workload_definition/query_text_registry.py
register(schema_name, mapping)
classmethod
Register an in-memory query_text_id → SQL mapping.
This is useful for testing or for schemas whose texts are generated programmatically and should not be persisted to disk. Any existing cached entry for schema_name is replaced.
Parameters
schema_name:
The schema identifier.
mapping:
Dictionary from query_text_id to SQL string.
Source code in src/autoslo/workload_definition/query_text_registry.py
load_schema(schema_name, one_statement_per_query=True)
classmethod
Load and return the mapping for schema_name from disk.
Reads
{data_root}/__query_texts/{schema_name}/query_texts.parquet.
Parameters
schema_name: The schema identifier. one_statement_per_query: Whether to enforce one statement per query.
Returns
dict[str, str]
Mapping from query_text_id to SQL string.
Raises
FileNotFoundError If the registry file for the schema does not exist.
Source code in src/autoslo/workload_definition/query_text_registry.py
save_schema(schema_name, mapping)
classmethod
Persist mapping to the standard registry path for schema_name.
Creates intermediate directories if they don't exist. After saving, the in-memory cache is updated.
Parameters
schema_name:
The schema identifier.
mapping:
Dictionary from query_text_id to SQL string.
Source code in src/autoslo/workload_definition/query_text_registry.py
clear_cache()
classmethod
_ensure_loaded(schema_name)
Populate the cache for schema_name from disk if not already done.
Source code in src/autoslo/workload_definition/query_text_registry.py
_create_registry_summary_file(schema_name)
classmethod
Helper to create a registry Parquet file from individual
query text files for a schema. Expects the files to be in
{data_root}/__query_texts/{schema_name}/ with names like
{query_text_id}.sql containing the SQL text.
Parameters
schema_name: The schema identifier.