Tableau Analytics Extensions

Enhanced Advanced

Introduction

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

Tableau Analytics Extensions are API requests made from Tableau to an external service that has been configured to respond correctly to these requests. Connect, along with the Python and R 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 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.

Python extensions

Enhanced Advanced

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 fastapitableau package documentation).

Publishing to Posit Connect

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

All content deployed to 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 Connect, it is recommended that each extension be assigned a unique vanity URL.

Troubleshooting

When diagnosing authentication errors within Tableau, be sure to confirm your installation’s compliance with the Tableau and Posit Connect product requirements.

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

Additional help can be found in the fastapitableau package documentation

R extensions

Enhanced Advanced

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 plumbertableau package documentation. The package documentation also provides a simple Getting Started example.

Publishing to Posit 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 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 Connect, it is recommended that each extension be assigned a unique vanity URL.

Troubleshooting

When diagnosing authentication errors within Tableau, be sure to confirm your installation’s compliance with the Tableau and Posit Connect product requirements.

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 Connect, set the environment variable DEBUGME to a value that includes plumbertableau. These log messages appear in the Posit Connect application log for the extension. A Connect administrator can also enable logging for Tableau requests by setting TableauIntegration.Logging=true.

Additional help can be found in the plumbertableau package documentation.

Configuring Tableau

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