> 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 auto-detects whether each set-op input is already partitioned compatibly and can use a direct exchange. 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.

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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
