Query (SQL++)
Enumerations
- enum couchbase_columnar.query.QueryScanConsistency(value)
Represents the various scan consistency options that are available.
Valid values are as follows:
- NOT_BOUNDED = <QueryScanConsistency.NOT_BOUNDED: 'not_bounded'>
Indicates that no specific consistency is required, this is the fastest options, but results may not include the most recent operations which have been performed.
- REQUEST_PLUS = <QueryScanConsistency.REQUEST_PLUS: 'request_plus'>
Indicates that the results to the query should include all operations that have occurred up until the query was started. This incurs a performance penalty of waiting for the index to catch up to the most recent operations, but provides the highest level of consistency.
Options
- class couchbase_columnar.options.QueryOptions(**kwargs: Unpack[QueryOptionsKwargs])
Available options for columnar query operation.
Timeout will default to cluster setting if not set for the operation.
Note
Options marked VOLATILE are subject to change at any time.
- Parameters:
deserializer (Optional[Deserializer]) – Specifies a
Deserializer
to apply to results. Defaults to None (DefaultJsonDeserializer
).lazy_execute (Optional[bool]) – VOLATILE If enabled, the query will not execute until the application begins to iterate over results. Defaulst to None (disabled).
named_parameters (Optional[Dict[str,
JSONType
]]) – Values to use for positional placeholders in query.positional_parameters (Optional[List[
JSONType
]]) – , optional): Values to use for named placeholders in query.priority (Optional[bool]) – Indicates whether this query should be executed with a specific priority level.
query_context (Optional[str]) – Specifies the context within which this query should be executed.
raw (Optional[Dict[str, Any]]) – Specifies any additional parameters which should be passed to the Columnar engine when executing the query.
read_only (Optional[bool]) – Specifies that this query should be executed in read-only mode, disabling the ability for the query to make any changes to the data.
scan_consistency (Optional[QueryScanConsistency]) – Specifies the consistency requirements when executing the query.
timeout (Optional[timedelta]) – Set to configure allowed time for operation to complete. Defaults to None (75s).
Results
BlockingQueryResult
- class couchbase_columnar.result.BlockingQueryResult
- cancel()
Cancel streaming the query results.
VOLATILE This API is subject to change at any time.
- Return type:
- rows()
Retrieve the rows which have been returned by the query.
- Return type:
BlockingIterator
- Returns:
A blocking iterator for iterating over query results.
- get_all_rows()
Convenience method to load all query results into memory.
Example
Read all rows from simple query:
q_str = 'SELECT * FROM `travel-sample`.inventory WHERE country LIKE 'United%' LIMIT 2;' q_rows = cluster.execute_query(q_str).all_rows()
- metadata()
Get the query metadata.
- Return type:
QueryMetadata
- Returns:
A QueryMetadata instance (if available).
- Raises:
RuntimeError – When the metadata is not available. Metadata is only available once all rows have been iterated.
QueryMetadata
- class couchbase_columnar.query.QueryMetadata
- request_id()
Get the request ID which is associated with the executed query.
- Return type:
- Returns:
The request ID which is associated with the executed query.
- warnings()
Get warnings that occurred during the execution of the query.
- Return type:
List
[QueryWarning
]- Returns:
Any warnings that occurred during the execution of the query.
- metrics()
Get the various metrics which are made available by the query engine.
- Return type:
QueryMetrics
- Returns:
A
QueryMetrics
instance.
QueryMetrics
- class couchbase_columnar.query.QueryMetrics
- elapsed_time()
Get the total amount of time spent running the query.
- Return type:
- Returns:
The total amount of time spent running the query.
- execution_time()
Get the total amount of time spent executing the query.
- Return type:
- Returns:
The total amount of time spent executing the query.
- result_count()
Get the total number of rows which were part of the result set.
- Return type:
- Returns:
The total number of rows which were part of the result set.
- result_size()
Get the total number of bytes which were generated as part of the result set.
- Return type:
- Returns:
The total number of bytes which were generated as part of the result set.
QueryWarning
Cancellation
Warning
VOLATILE This API is subject to change at any time.
CancelToken
- class couchbase_columnar.query.CancelToken(token: Event, poll_interval: float = 0.25)
Token that can be passed into a blocking query enabling streaming to be canceled.
VOLATILE This API is subject to change at any time.
- cancel()
Set the token’s event to trigger streaming cancellation.
VOLATILE This API is subject to change at any time.
- Return type: