fix(dwh): align adapter sampling contract
This commit is contained in:
@@ -17,6 +17,8 @@ from tht.rest.explain import parse_text_plan
|
||||
def run_controlled_rest(client, sql: str, *, limit: int) -> ExecResult:
|
||||
# Guard read-only client-side anche sul path REST (D7): non delegare l'unica verifica
|
||||
# al server. Stesso check strutturale del path diretto.
|
||||
if limit <= 0:
|
||||
raise ValueError("limit must be a positive integer")
|
||||
assert_read_only(sql)
|
||||
final_sql, injected = _inject_limit(sql, limit)
|
||||
start = time.monotonic()
|
||||
@@ -46,14 +48,3 @@ def explain_rest(client, sql: str) -> PlanSummary:
|
||||
except RestError as e:
|
||||
raise ExecutionError(str(e)) from e
|
||||
return parse_text_plan(lines)
|
||||
|
||||
|
||||
def sample_column_rest(
|
||||
client, schema: str, table: str, column: str, *, limit: int
|
||||
) -> list[object]:
|
||||
rows = client.top_values(schema, table, column, limit)
|
||||
return [row["value"] for row in rows if row.get("value") is not None]
|
||||
|
||||
|
||||
def distinct_values_rest(client, schema: str, table: str, column: str) -> list[object]:
|
||||
return sample_column_rest(client, schema, table, column, limit=1000)
|
||||
|
||||
Reference in New Issue
Block a user