Skip to content

Tableau Analytics Extensions#

Introduction#

RStudio Connect can be used to host Tableau Analytics Extensions built in both R and Python. These extensions can be used from Tableau workbooks to make realtime requests from Tableau to R.

Tableau Analytics Extensions are API requests made from Tableau to an external service that has been configured to respond correctly to these requests. RStudio Connect, along with the R and Python packages designed to support the development of these extensions, has been designed to function as a valid Tableau Analytics Extension. Tableau makes requests to /evaluate, and RStudio Connect reroutes requests from Tableau to the appropriate endpoint indicated in the request itself.

Tableau extensions must return a single vector of values equal in length to the input data.

R Extensions#

R extensions for Tableau are built using the plumbertableau R package. This package enhances Plumber APIs so they can function as valid Tableau extensions. The following example illustrates an API that functions as a Tableau extension:

library(plumber)
library(plumbertableau)

#* @apiTitle String utilities
#* @apiDescription Simple functions for mutating strings

#* Capitalize incoming text
#* @tableauArg str_value:[character] Strings to be capitalized
#* @tableauReturn [character] A capitalized string(s)
#* @post /capitalize
function(str_value) {
  toupper(str_value)
}

# The Plumber router modifier tableau_extension is required
#* @plumber
tableau_extension

Additional details about building Tableau extensions using plumbertableau can be found in the package documentation. The package documentation also provides a simple Getting Started example.

Publishing to RStudio Connect#

At their core, Tableau Analytics Extensions built in R are Plumber APIs. As a result, the process for publishing these extensions is identical to publishing any other Plumber API.

All content deployed to RStudio Connect is assigned a content GUID. This is the default value used in the URL assigned to the content. In order to make it easier for Tableau users to use analytics extensions published to RStudio Connect, it is recommended that each extension be assigned a unique vanity URL.

Troubleshooting#

plumbertableau uses the debugme R package to provide additional logging detail upon request. In order to enable additional logging for a Tableau Analytics Extension published to RStudio Connect, set the environment variable DEBUGME to a value that includes plumbertableau. These log messages will appear in the RStudio Connect application log for the extension. An RStudio Connect administrator can also enable logging for Tableau requests by setting TableauIntegration.Logging=true.

Python Extensions#

Python extensions for Tableau are built using the fastapitableau Python package. This package provides methods to enable FastAPI endpoints to function as valid Tableau extensions. The following example illustrates an API that functions as a Tableau extension:

from typing import List

from fastapitableau import FastAPITableau

app = FastAPITableau(
    title="Simple Example",
    description="A *simple* example FastAPITableau app.",
    version="0.1.0",
)


@app.post("/capitalize")
async def capitalize(text: List[str]) -> List[str]:
    capitalized = [t.upper() for t in text]
    return capitalized

Additional details about building Tableau extensions using fastapitableau can be found in the package documentation).

Publishing to RStudio Connect#

Because fastapitableau is an extension of FastAPI, publishing these extensions to RStudio Connect is the same as publishing any other FastAPI content.

All content deployed to RStudio Connect is assigned a content GUID. This is the default value used in the URL assigned to the content. In order to make it easier for Tableau users to use analytics extensions published to RStudio Connect, it is recommended that each extension be assigned a unique vanity URL.

Troubleshooting#

Errors that occur in a running fastapitableau extension will be captured in the RStudio Connect application logs. An RStudio Connect administrator can also enable logging for Tableau requests by setting TableauIntegration.Logging=true.

Configuring Tableau#

For information about configuring Tableau and RStudio Connect, please see Tableau Analytics Extensions with RStudio Connect