Package tech.ydb.yoj.repository.ydb.yql
Class YqlLimit
java.lang.Object
tech.ydb.yoj.repository.ydb.yql.YqlLimit
- All Implemented Interfaces:
YqlStatementPart<YqlLimit>
Represents a
Note that YDB does not support
LIMIT ... [OFFSET ...] clause in a YQL statement.
Note that YDB does not support
OFFSET without LIMIT, so "row offset" cannot be set directly.
To return the maximum possible amount of rows, you must know the YDB ResultSet row limit (e.g., defined by YDB_KQP_RESULT_ROWS_LIMIT
environment variable for local YDB-in-Docker), and use YqlLimit.range(offset, max rows + offset).
If you have a specific limit < max rows, it's much better to use YqlLimit.range(offset, limit + offset),
of course.- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic YqlLimitempty()intgetType()booleanisEmpty()static YqlLimitrange(long from, long to) Creates a limit clause to fetch rows in the half-open range[from, to).longsize()Deprecated, for removal: This API element is subject to removal in a future version.static YqlLimittop(long n) Creates a limit clause to fetch topnrows, as if by callingrange(0, n).toString()<T extends tech.ydb.yoj.repository.db.Entity<T>>
StringtoYql(@NonNull tech.ydb.yoj.repository.db.EntitySchema<T> schema) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface tech.ydb.yoj.repository.ydb.yql.YqlStatementPart
combine, toFullYql
-
Field Details
-
EMPTY
Gives aLIMITclause that will always return an empty range (LIMIT 0).
-
-
Method Details
-
range
Creates a limit clause to fetch rows in the half-open range[from, to).- Parameters:
from- first row index, counting from 0, inclusiveto- last row index, counting from 0, exclusive. Must be>= from- Returns:
- limit clause to fetch
(to - from)rows in range[from, to)
-
top
Creates a limit clause to fetch topnrows, as if by callingrange(0, n).- Parameters:
n- number of rows to fetch- Returns:
- limit clause to fetch top
nrows
-
empty
- Returns:
- limit clause that fetches no rows
- See Also:
-
size
Deprecated, for removal: This API element is subject to removal in a future version.Please calculate the maximum number of rows fetched by thisLIMITclause by usingYqlLimit.getLimit()andYqlLimit.getOffset()instead. -
isEmpty
public boolean isEmpty()- Returns:
trueif thisYqlLimitrepresents an empty range (LIMIT 0);falseotherwise
-
getPriority
public int getPriority()- Specified by:
getPriorityin interfaceYqlStatementPart<YqlLimit>
-
getType
- Specified by:
getTypein interfaceYqlStatementPart<YqlLimit>
-
getYqlPrefix
- Specified by:
getYqlPrefixin interfaceYqlStatementPart<YqlLimit>
-
toYql
public <T extends tech.ydb.yoj.repository.db.Entity<T>> String toYql(@NonNull @NonNull tech.ydb.yoj.repository.db.EntitySchema<T> schema) - Specified by:
toYqlin interfaceYqlStatementPart<YqlLimit>
-
toString
-
LIMITclause by usingYqlLimit.getLimit()andYqlLimit.getOffset()instead.