Tableau Analytics Extensions
Introduction
Posit 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. Posit 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 Posit 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 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 Posit 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 Posit 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 Posit Connect, set the environment variable DEBUGME
to a value that includes plumbertableau
. These log messages will appear in the Posit Connect application log for the extension. An Posit Connect administrator can also enable logging for Tableau requests by setting TableauIntegration.Logging=true
.
Additional help may be found in the plumbertableau
package documentation.
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
= FastAPITableau(
app ="Simple Example",
title="A *simple* example FastAPITableau app.",
description="0.1.0",
version
)
@app.post("/capitalize")
async def capitalize(text: List[str]) -> List[str]:
= [t.upper() for t in text]
capitalized return capitalized
Additional details about building Tableau extensions using fastapitableau
can be found in the package documentation).
Publishing to Posit Connect
Because fastapitableau
is an extension of FastAPI, publishing these extensions to Posit Connect is the same as publishing any other FastAPI content.
All content deployed to Posit 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 Posit 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 will be captured in the Posit Connect application logs. An Posit Connect administrator can also enable logging for Tableau requests by setting TableauIntegration.Logging=true
.
Additional help may be found in the fastapitableau
package documentation
Configuring Tableau
For information about configuring Tableau and Posit Connect, please see Tableau Analytics Extensions with Posit Connect