> For the complete documentation index, see [llms.txt](https://docs.pinot.apache.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pinot.apache.org/build-with-pinot/querying-and-sql/multi-stage-query/hints.md).

# Hints

Multi-stage query engine behavior can be customized with hints. Hints are provided as a comment, for example `/* hintType(hint1='value1',hint2='value2') */`.

Apache Pinot supports the following hints:

* `aggOptions`, explained in [aggregate operator](/build-with-pinot/querying-and-sql/multi-stage-query/operator-types/aggregate.md#hints).
* `windowOptions`, explained in [window operator](/build-with-pinot/querying-and-sql/multi-stage-query/operator-types/window.md#hints).
* `joinOptions`, explained in [join operator](/build-with-pinot/querying-and-sql/multi-stage-query/operator-types/hash_join.md#hints).
* `setOpOptions`, explained in [union](/build-with-pinot/querying-and-sql/multi-stage-query/operator-types/union.md#hints), [intersect](/build-with-pinot/querying-and-sql/multi-stage-query/operator-types/intersect.md#hints), and [minus](/build-with-pinot/querying-and-sql/multi-stage-query/operator-types/minus.md#hints).

## setOpOptions

Use `setOpOptions` to control the exchange Pinot inserts below `UNION`, `UNION ALL`, `INTERSECT`, and `EXCEPT` / `MINUS`.

### is\_colocated\_by\_set\_op\_keys

Type: Boolean

Default: planner chosen

When the option is unset, the V1 planner uses a local exchange for `UNION ALL` inputs and auto-detects whether other set-op inputs are already partitioned compatibly. You can override that decision explicitly:

* `'true'` forces a pre-partitioned direct exchange on every input.
* `'false'` forces a shuffled hash exchange on every input.

For `UNION ALL`, only `'false'` changes the default behavior. Use it as a per-query fallback when retaining the input worker layout causes undesirable skew. If input worker counts do not align, Pinot automatically promotes the affected local exchange to a hash exchange.

This hint is only honored by the V1 planner. The V2 physical optimizer ignores it and determines set-op colocation on its own.

Pinot accepts the hint in two places:

* Inline on the first branch:

```sql
SELECT /*+ setOpOptions(is_colocated_by_set_op_keys='true') */ col FROM a
UNION ALL
SELECT col FROM b
```

* On an outer `SELECT` that wraps the set operation:

```sql
SELECT /*+ setOpOptions(is_colocated_by_set_op_keys='true') */ *
FROM (
  SELECT col FROM a
  INTERSECT
  SELECT col FROM b
)
```

{% hint style="warning" %}
Only force `'true'` when every input is partitioned compatibly on one or more projected columns, so equal full output rows land on the same worker. If that is not true, `INTERSECT`, `EXCEPT`, and plain `UNION` can return wrong results. `UNION ALL` is always safe because it only concatenates rows.
{% endhint %}

Use the outer-wrap form for plain `UNION`, which Pinot rewrites before the exchange rule resolves the inline hint. Prefer the outer-wrap form for nested `INTERSECT` or `EXCEPT` queries too when you want the hint to apply at every set-op level.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pinot.apache.org/build-with-pinot/querying-and-sql/multi-stage-query/hints.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
