Preview transformations

async AsyncCogniteClient.transformations.preview(
query: str | None = None,
convert_to_string: bool = False,
limit: int | None = 100,
source_limit: int | None = 100,
infer_schema_limit: int | None = 10000,
timeout: int | None = 240,
) TransformationPreviewResult

Preview the result of a query.

Parameters:
  • query (str | None) – SQL query to run for preview.

  • convert_to_string (bool) – Stringify values in the query results, default is False.

  • limit (int | None) – Maximum number of rows to return in the final result, default is 100.

  • source_limit (int | None) – Maximum number of items to read from the data source or None to run without limit, default is 100.

  • infer_schema_limit (int | None) – Limit for how many rows that are used for inferring result schema, default is 10 000.

  • timeout (int | None) – Number of seconds to wait before cancelling a query. The default, and maximum, is 240.

Returns:

Result of the executed query

Return type:

TransformationPreviewResult

Examples

Preview transformation results as schema and list of rows:

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>>
>>> query_result = client.transformations.preview(query="select * from _cdf.assets")

Preview transformation results as pandas dataframe:

>>> df = client.transformations.preview(query="select * from _cdf.assets").to_pandas()

Notice that the results are limited both by the limit and source_limit parameters. If you have a query that converts one source row to one result row, you may need to increase the source_limit. For example, given that you have a query that reads from a raw table with 10,903 rows

>>> result = client.transformations.preview(
...     query="select * from my_raw_db.my_raw_table", limit=None
... )
>>> print(result.results)  # 100

To get all rows, you also need to set the source_limit to None:

>>> result = client.transformations.preview(
...     query="select * from my_raw_db.my_raw_table", limit=None, source_limit=None
... )
>>> print(result.results)  # 10903