Materialize Documentation
s
Join the Community github/materialize

FETCH

New in v0.5.3.

FETCH retrieves rows from a query using a cursor previously opened with DECLARE.

Syntax

FETCH FORWARD ALL count FROM cursor_name WITH ( option_name = option_value , )
Field Use
count The number of rows to retrieve. Defaults to 1 if unspecified.
cursor_name The name of an open cursor.

WITH option

The following option is valid within the WITH clause.

Option name Value type Default Describes
timeout interval None When fetching from a TAIL cursor, complete if there are no more rows ready after this timeout. The default will cause FETCH to wait for at least one row to be available.

New in v0.6.0.

Changed in v0.6.1: The default timeout is None, rather than 0s.

Details

FETCH will return at most the specified count of available rows.

New in v0.6.1: Specifying a count of ALL indicates that there is no limit on the number of rows to be returned.

For TAIL queries, FETCH by default will wait for rows to be available before returning. Specify a timeout of 0s to return only rows that are immediately available.