Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface DataTableReader

A DataTableReader allows iteration over summary or underlying data by pages. The page size is established when the DataTableReader is created. (See getLogicalTableDataReaderAsync, getSummaryDataReaderAsync, or getUnderlyingTableDataReaderAsync.) The normal sequence of operations would be to

  1. Create the DataTableReader for the desired DataTable.
  2. Use DataTableReader.totalRowCount or DataTableReader.pageCount to discover how many rows or pages are in the desired DataTable.
  3. Call DataTableReader.getPageAsync() to get the page(s) desired. Each page is a DataTable for that page. Alternatively, based on the DataTableReader.totalRowCount, DataTableReader.getAllPagesAsync can be used to fetch the entire DataTable.
  4. Call DataTableReader.releaseAsync() to free up resources.

Notes for usage of a DataTableReader:

  1. Since DataTableReaders consume server resources, an inactive DataTableReader will be automatically released after 60 minutes of inactivity. (A new DataTableReader can be created at that time, if needed.)
  2. Calling getPageAsync() after an explicit or automatic releaseAsync() will throw an exception.
  3. Only one active DataTableReader per logical table id is supported.
  4. There are still limits on the number of rows supported for underlying and logical data table readers. The default limit is approximately 1 million rows of data for getUnderlyingTableDataReaderAsync, and approximately 32 million cells (rows * columns) for getLogicalTableDataReaderAsync. Administrators may change these limits to better match computing resources with the Tableau Server (Cloud) or Tableau Desktop options: ExtensionsAndEmbeddingReaderRowLimit for getUnderlyingTableDataReaderAsync or ExtensionsAndEmbeddingReaderCellLimit for getLogicalTableDataReaderAsync.

Hierarchy

  • DataTableReader

Index

Properties

pageCount

pageCount: number
returns

The number of pages in the full data table. The last page could be a partial page.

totalRowCount

totalRowCount: number
returns

The number of rows in the full data table.

Methods

getAllPagesAsync

  • getAllPagesAsync(maxRows?: undefined | number): Promise<DataTable>
  • Get all the pages of data into a single DataTable. Calls to getAllPagesAsync() after releaseAsync() will throw an exception. To protect against possible browser failure, getAllPagesAsync will cap the data at a maximum of 400 pages. With a default pageRowCount of 10,000 this will give you a maximum of 4,000,000 rows of data.

    If sizes are larger than this, please process your data in page size chunks.

    Parameters

    • Optional maxRows: undefined | number

      Limits the request to maxRows. If maxRows === 0, requests all rows.

    Returns Promise<DataTable>

    A DataTable containing all the data available to the DataTableReader with the maximum page count above.

    // To simplify the example, we assume we have less than 4m rows of data
    // Since we are fetching all of the data, use the default page size in getSummaryDataReaderAsync
    const dataTableReader = await worksheet.getSummaryDataReaderAsync();
    const dataTable = await dataTableReader.getAllPagesAsync();
    await dataTableReader.releaseAsync();
    // ... process the data table ...

getPageAsync

  • getPageAsync(pageNumber: number): Promise<DataTable>
  • Get a page of data. The page is returned as a DataTable. Calls to getPageAsync() after releaseAsync() will throw an exception.

    Parameters

    • pageNumber: number

      The page number (zero-indexed) to fetch. The page number should be treated like an array index with range: 0 <= pageNumber < pageCount.

    Returns Promise<DataTable>

    A DataTable containing the requested page. The number of rows returned can be less than the page size at the end of the data.

    const pageRowCount = 200;
    const dataTableReader = await worksheet.getSummaryDataReaderAsync(pageRowCount, options);
    for (let currentPage = 0; currentPage < dataTableReader.pageCount; currentPage++) {
      const currentPageDataTable = await dataTableReader.getPageAsync(currentPage);
      // ... process current page ...
    }
    await dataTableReader.releaseAsync();

releaseAsync

  • releaseAsync(): Promise<void>
  • Release all resources held by the DataTableReader. Calling this when done with the DataTableReader is required practice as it frees up resources. Calls to getPageAsync() after releaseAsync() will throw an exception.

    Returns Promise<void>