public final class RowLimit extends Object
LIMIT N, FETCH FIRST N ROWS ONLY,
TOP N, or OFFSET m [FETCH NEXT n ROWS ONLY] clause
is present and the count/offset expressions are resolvable from the
parser AST. Column lineage (ORDER BY refs, output sources, etc.) is
unchanged by row-limit metadata.
count is the verbatim text of the count
expression — what the SQL author wrote, e.g. "10",
"100", "ALL", "NULL", or even "-10"
if the parser admits a signed literal. This mirrors the slice-22
FrameBound.offsetLiteral convention: capture presentation
accurately, do not impose a numeric interpretation that would be
dialect-dependent or lossy for parameterized counts (LIMIT ?,
LIMIT :n, TOP (@v)). Downstream governance code is
responsible for parsing the count into a number when it needs one.
count is normally non-null. The single
exception is RowLimitKind.OFFSET_FETCH when the SQL author
wrote only an offset and no fetch count
(PG OFFSET 5 [ROWS], Oracle/MSSQL OFFSET 5 ROWS
without FETCH NEXT). In that case count is
null and offset is non-null.
offset is non-null for any row-limit clause
that carries an offset slot in the source SQL:
LIMIT N OFFSET M (kind RowLimitKind.LIMIT).LIMIT M, N (kind
RowLimitKind.LIMIT; offset = M).OFFSET m FETCH FIRST n (kind
RowLimitKind.FETCH_FIRST).SKIP m FIRST n (kind
RowLimitKind.FETCH_FIRST) and
SKIP m LIMIT n (kind RowLimitKind.LIMIT).OFFSET m ROWS [FETCH NEXT n ROWS ONLY]
(kind RowLimitKind.OFFSET_FETCH).Set-op outer row-limit (e.g. UNION ALL ... LIMIT 5)
continues to be rejected by rejectSetOpRowLimit with
SET_OP_ROW_LIMIT_NOT_SUPPORTED (slice 72 lifts).
Immutable. Value equality on (kind, count, offset).
| Constructor and Description |
|---|
RowLimit(RowLimitKind kind,
String count,
String offset) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
String |
getCount()
Verbatim text of the count expression
(
TExpression.toString()). |
RowLimitKind |
getKind()
Non-null.
|
String |
getOffset()
Verbatim text of the offset expression
(
TExpression.toString()). |
int |
hashCode() |
String |
toString() |
public RowLimit(RowLimitKind kind, String count, String offset)
public RowLimitKind getKind()
RowLimitKind's four values; identifies
the SQL surface form the user wrote so downstream consumers can
distinguish e.g. TOP N from LIMIT N.public String getCount()
TExpression.toString()). Non-null for RowLimitKind.LIMIT,
RowLimitKind.FETCH_FIRST, and RowLimitKind.TOP.
May be null only for RowLimitKind.OFFSET_FETCH
when the SQL author wrote only an offset and no fetch count
(OFFSET 5 ROWS without FETCH NEXT).
Downstream code is responsible for any numeric validation of
the count text.public String getOffset()
TExpression.toString()). Non-null whenever the source
SQL carries an offset slot; null otherwise. See the
class-level javadoc for the full enumeration of offset-bearing
surfaces.