Skip to main content
get_records_and_decode(table_name=None, offset=0, limit=-9999, encoding=‘binary’, options=, record_type=None, force_primitive_return_types=True)[source]

Retrieves records from a given table, optionally filtered by an expression and/or sorted by a column. This operation can be performed on tables and views. Records can be returned encoded as binary, json, or geojson.

This operation supports paging through the data via the input parameter offset and input parameter limit parameters. Note that when paging through a table, if the table (or the underlying table in case of a view) is updated (records are inserted, deleted or modified) the records retrieved may differ between calls based on the updates applied.

Parameters

table_name (str) –

Name of the table or view from which the records will be fetched, in [schema_name.]table_name format, using standard name resolution rules.

offset (long) –

A positive integer indicating the number of initial results to skip (this can be useful for paging through the results). The default value is 0. The minimum allowed value is 0. The maximum allowed value is MAX_INT.

limit (long) –

A positive integer indicating the maximum number of results to be returned, or END_OF_SET (-9999) to indicate that the maximum number of results allowed by the server should be returned. The number of records returned will never exceed the server’s own limit, defined by the max_get_records_size parameter in the server configuration. Use output parameter has_more_records to see if more records exist in the result to be fetched, and input parameter offset and input parameter limit to request subsequent pages of results. The default value is -9999.

encoding (str) –

Specifies the encoding for returned records; one of binary, json, or geojson. Allowed values are:

  • binary

  • json

  • geojson

  • arrow

The default value is ‘binary’.

options (dict of str to str) –

Allowed keys are:

  • expression – Filter expression to apply to the table.

  • fast_index_lookup – Indicates if indexes should be used to perform the lookup for a given expression if possible. Only applicable if there is no sorting, the expression contains only equivalence comparisons based on existing tables indexes and the range of requested values is from [0 to END_OF_SET]. Allowed values are:

    • true

    • false

    The default value is ‘true’.

  • sort_by – Column that the data should be sorted by. Empty by default (i.e. no sorting is applied).

  • sort_order – String indicating how the returned values should be sorted - ascending or descending. If sort_order is provided, sort_by has to be provided. Allowed values are:

    • ascending

    • descending

    The default value is ‘ascending’.

The default value is an empty dict ( ).

record_type (RecordType or None) –

The record type expected in the results, or None to determine the appropriate type automatically. If known, providing this may improve performance in binary mode. Not used in JSON mode. The default value is None.

force_primitive_return_types (bool) –

If True, then OrderedDict objects will be returned, where string sub-type columns will have their values converted back to strings; for example, the Python datetime structs, used for datetime type columns would have their values returned as strings. If False, then Record objects will be returned, which for string sub-types, will return native or custom structs; no conversion to string takes place. String conversions, when returning OrderedDicts, incur a speed penalty, and it is strongly recommended to use the Record object option instead. If True, but none of the returned columns require a conversion, then the original Record objects will be returned. Default value is True.

Returns

A dict with the following entries–

table_name (str) –

Value of input parameter table_name.

type_name (str) –

The name of the type of the returned records.

type_schema (str) –

Avro schema of output parameter records_binary or output parameter records_json.

total_number_of_records (long) –

Total/Filtered number of records.

has_more_records (bool) –

Too many records. Returned a partial set.

info (dict of str to str) –

Additional information.

records (list of Record) –

A list of Record objects which contain the decoded records.