Overview of Data Query
The Data Query feature allows exporting data from Zuora using asynchronous, read-only SQL queries, supporting multiple objects and providing API and UI access.
The Data Query feature enables you to export data from your Zuora tenant by performing asynchronous, read-only SQL queries. Because of the flexibility of SQL, you can use a single data query to retrieve data from multiple objects that have not been pre-joined by Zuora. See the following features of Data Query:
- Data Query supports the SQL-based job to query all your tenant’s data.
- Data Query provides easy-to-use POST and GET API.
- Data Query provides User Interface for you to submit queries through the simple text box under Extension Studio > Data Query.
- Data Query supports the encryption feature when using personal RSA key pairs.
- Data Query does not support synchronous queries. All queries are asynchronous.
- Data Query only supports the read-only SQL statements. It does not support non-read only SQL statements such as UPDATE, DELETE, INSERT, ALTER TABLE, and so on.
Typically you can use Data Query in case that you:
- Query from tables that are not available in other data extraction applications
- Make more JOINs than Data Source Exports or Reporting can support
- Prefer using SQL functions rather than ZOQL
- Create Workflows that need to work with data
Using Data Query
You can use Data Query through API, User Interface, and Workflow tasks.
When you submit a data query, you can select one of the following data sources to run the query:
- Live: Zuora transactional databases, which are updated in near real-time.
- Zuora Warehouse: the high-performance data warehouse provided by Zuora. This option is available only if you have the Zuora Warehouse feature enabled. For more information, see Zuora Warehouse.
You can use Data Query through API. For information, see Use Data Query through API.
Data Query returns timestamps in different time zones depending on the data source:
- Live: Uses tenant’s preferred timezone
- Zuora Warehouse: Uses PST (America/Los_Angeles)
This behavior is expected and consistent across US, EU, APAC regions. If comparing results between Live and Warehouse, convert timestamps to a common timezone (recommended: UTC).
Helpful snippets:
- UTC: SELECT at_timezone(createddate, ‘UTC’) AS created_utc
- Pacific: SELECT at_timezone(createddate, ‘America/Los_Angeles’) AS created_pacific
Here are a few examples:
Convert to UTC
Convert to Pacific Time (DST-aware)
Using Data Query through user interface
You can create new data queries, save data queries, and view the query history through Data Query UI. See Using Data Query through User Interface for the details.
Using Data Query through workflow tasks
Export data from your Zuora tenant through workflow tasks. For more information see Retrieve: Data Query.
Notes and limitations
Data Query has been adapted from Trino v351.
Query processing limitations
See the query processing limitations in the table below.
When querying large transactional tables such as InvoiceItem, CreditMemoItem, DebitMemoItem, and TaxationItem, you should include additional filtering logic in the WHERE clause to ensure that the number of input records is less than 10 million. If the number of input records is greater than 10 million, the query will fail.
Examples for Query Processing Limitations in Data Query Live
For example, suppose that the InvoiceItem table contains a total of 10,200,000 records and the Subscription table contains a total of 100,000 records, and you submit the following data queries:
-
SELECT * FROM InvoiceItem- Number of input records: 10,200,000
- Number of output records: 0
This query will fail.
-
SELECT * FROM InvoiceItemWHERE UpdatedDate >= TIMESTAMP '2018-06-02 18:17:07 -07:00'- Number of input records: 600,000
- Number of output records: 600,000
This query will fail.
-
SELECT * FROM InvoiceItemWHERE UpdatedDate >= TIMESTAMP '2018-06-02 18:17:07 -07:00' LIMIT 100000- Number of input records: 600,000
- Number of output records: 100,000
This query will succeed.
-
SELECT * FROM InvoiceItem, Subscription
WHERE InvoiceItem.id = ‘c92c8f9-61e3-1799-0161-e4d0317a088e’
- Number of input records in
InvoiceItemtable: 1 - Number of input records in
Subscriptiontable: 100,000 - Number of output records: 100,000
This query will succeed.
- Number of input records in
-
SELECT * FROM InvoiceItem
JOIN Subscription ON Subscription.id = InvoiceItem.subscriptionid
WHERE InvoiceItem.id = ‘c92c8f9-61e3-1799-0161-e4d0317a088e’
- Number of input records in
InvoiceItemtable: 1 - Number of input records in
Subscriptiontable: 100,000 - Number of output records: 1
This query will succeed.
- Number of input records in
For another example, suppose that you have Multi-entity enabled in your tenant, and five query jobs in your Entity A are in the in_progress status. After switching to Entity B, if you submit another query job, the job will be in the accepted status because the maximum number of simultaneous queries for a tenant is five. This limitation applies at the tenant level.
Functionality Limitations
Data Query does not support currency rounding for billing objects. It returns raw data without rounding.
Retry behavior
Non-retryable queries are marked as failed if the query process is not successful.
Data Query makes up to three retries for retryable queries. If the first attempt and three retries all fail, the query is considered failed.
Note that the maximum processing time for each attempt is one hour.