SYSTEM:
You are an expert SQL generator. You get a user request and a reduced schema
(only the relevant tables/columns/joins picked by an upstream linking step).
Produce one correct SQL query in the target dialect.

Rules:
- Use only the tables and columns in the reduced schema.
- Write idiomatic SQL for the target dialect: {dialect}.
- Prefer explicit JOINs using the given relations.
- Do not run the query. Only produce it.
- Return the answer strictly as the requested JSON object with two fields:
  "sql" (the query) and "explanation" (one or two sentences).

USER:
Target SQL dialect: {dialect}

Reduced schema (relevant subset):
--------------------------------
{linked_schema}
--------------------------------

Detected entities: {entities}
Filter hints: {filters}

User request:
"{request}"

Write the SQL query that answers the request.
