> 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/release-1.5.0/users/user-guide-query/query-syntax/row-expression-comparison.md).

# Row Expression Comparison

***

## Row Expression

### ROW()

#### **Description**:

ROW value expressions is supported in Pinot in comparison contexts, enabling efficient keyset pagination queries. ROW expressions allow users to write cleaner multi-column comparisons like WHERE (col1, col2, col3) > (val1, val2, val3) instead of verbose nested conditions. The evaluation of row expression is based on the ([JOOQ transformations](https://www.jooq.org/doc/latest/manual/sql-building/conditional-expressions/comparison-predicate-degree-n/)) for the comparison operators.

#### **Syntax**:

Pinot supports implicit ROW-style expressions in comparison predicates using a parenthesized list of expressions on both sides of the comparator:

WHERE (col1, col2, col3) > (val1, val2, val3)

Supported comparison operators:

```
=, <>, <, <=, >, >=
```

Note: Explicit use of the ROW() keyword (e.g., WHERE ROW(col1, col2) = ROW(1, 2)) is not yet supported due to the current SQL parser configuration (SqlConformanceEnum.BABEL). Future improvements may enable explicit row value constructors.

#### **Note**:

* ROW comparisons are lexicographic, not element-wise
* Pinot does not materialize row types — it rewrites comparisons at planning time
* Rewrite complexity grows linearly with the number of columns
* Mixed data types are supported as long as pairwise comparisons are valid

#### **Sample Example Usage**:

**Equality (=)**

```sql
WHERE (a, b, c) = (x, y, z)
```

is rewritten to

```sql
WHERE a = x
  AND b = y
  AND c = z
```

**Greater Than (>)**

```sql
WHERE (a, b, c) > (x, y, z)
```

is rewritten to

```sql
WHERE a > x
   OR (a = x AND b > y)
   OR (a = x AND b = y AND c > z)
```

**Less Than (<)**

```sql
WHERE (a, b, c) < (x, y, z)
```

is rewritten to

```sql
WHERE a < x
OR (a = x AND b < y)
OR (a = x AND b = y AND c < z)
```


---

# 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/release-1.5.0/users/user-guide-query/query-syntax/row-expression-comparison.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.
