Skip to main content

Overview of Data Query

Zuora

Overview of Data Query

The Data Query feature enables you to export data from your Zuora tenant by performing asynchronous, read-only SQL queries. You can use the REST API to submit queries, check the status of queries, and obtain the exported data.

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 Platform > 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.

Using Data Query through API

To export data from your Zuora tenant through Data Query API:

  1. Construct a SQL query.

    For example:

    SELECT accountnumber, balance FROM Account WHERE Account.balance > 100
    

    See Constructing SQL Queries in Data Query for the supported SQL syntax, the available tables, and sample queries.

  2. Call Submit data query to submit the query and create a query job. Provide the query in the request body.

    You can request the query results in CSV, TSV, DSV or JSON format.

  3. Call Get data query job in the API or check your query listed on the Data Query page to track the status of the query job.

    Depending on the complexity of the query, you may need to call "Get data query job" several times, until the value of queryStatus in the response body is completedfailed, or cancelled.

    When the query job is complete, you can obtain the URL of the query results from the response body. For example:

    https://example.s3.us-west-2.amazonaws.com/3a3e85c4-96e7-486b-ae02-827120104301_24921638725108715.json?X-Amz-Security-Token=...

  4. Download the query results.

    Each row in the query results contains the requested fields of an object in your Zuora tenant. For example:

    accountnumber,balance
    A00253588,230.0
    A00253573,125.0
    A00255366,199.95
    ...
    

    If you requested the query results in JSON format, each row in the query results is a JSON object. The query results are not wrapped in a JSON array. For example:

    {"accountnumber":"A00253588","balance":230.0}
    {"accountnumber":"A00253573","balance":125.0}
    {"accountnumber":"A00255366","balance":199.95}
    ...
    

Using Data Query through User Interface

To export data from your Zuora tenant through Data Query User Interface:

  1. Navigate to Platform > Data Query.
  2. Click CREATE NEW DATA QUERY on the Data Query page.
  3. Enter a SQL query into the text box on the Create Data Query page. See Constructing SQL Queries in Data Query for the supported SQL syntax, the available tables, and sample queries.

  4. Click SUBMIT QUERY.

Using Data Query through Workflow Tasks

To export data from your Zuora tenant through Workflow tasks, see Retrieve: Data Query.

Limitations

Query Processing Limitations

  • Data queries can input a maximum of 1 million records per table, after filters have been applied.
  • Data queries can output a maximum of 100,000 records.
  • Data Query can simultaneously process a maximum of 5 queries per tenant. If 5 queries are currently being processed, Data Query will queue up to 10 additional queries to be processed. Any queries beyond the 10 queued queries will fail.
  • Data Query processes each query for a maximum of 1 hour.
  • Data Query allocates a maximum of 2 GB of memory to each query.
  • Data Query enforces a maximum indices limit of 5,000 when using Index Join. Therefore, the unique value used in the WHERE clause must limit the number of records being returned by the left table to 5,000.

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 1 million. If the number of input records is greater than 1 million, the query will fail.

For example, suppose that the InvoiceItem table contains a total of 1,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: 1,200,000
    • Number of output records: 0

    This query will fail.

  • SELECT * FROM InvoiceItem 
    WHERE UpdatedDate >= TIMESTAMP '2018-06-02 18:17:07 -07:00'
    
    • Number of input records: 150,000
    • Number of output records: 150,000

    This query will fail.

  • SELECT * FROM InvoiceItem 
    WHERE UpdatedDate >= TIMESTAMP '2018-06-02 18:17:07 -07:00' LIMIT 100000
    
    • Number of input records: 150,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 InvoiceItem table: 1
    • Number of input records in Subscription table: 100,000
    • Number of output records: 100,000

    This query will succeed.

  • SELECT * FROM InvoiceItem 
    JOIN Subscription ON Subscription.id = InvoiceItem.subscriptionid 
    WHERE InvoiceItem.id = 'c92c8f9-61e3-1799-0161-e4d0317a088e' 
    
    • Number of input records in InvoiceItem table: 1
    • Number of input records in Subscription table: 100,000
    • Number of output records: 1

    This query will succeed.

Functional Limitations

  • Data Query does not support foreign currency conversion. All monetary values are exported in the original transaction currency.