Skip to main content
Dependencies:
  • ProphecySparkBasicsPython 0.0.1+
Cluster requirements:
  • UC dedicated clusters 14.3+ supported
  • UC standard clusters 15.4+ supported
  • Livy clusters not supported
Enriches the DataFrame by adding column(s) with content from REST API output based on the given configuration.

Parameters

Each property can either be set as a static value or a value from an existing column of the input DataFrame. All input parameters are expected to be in string format. Other column types such as array/JSON/struct can be created using combination of aggregate/window gems along with reformat component and then can be cast as string prior to passing the column in RestAPIEnrich gem as needed. The following table lists all parameters of the RestAPIEnrich gem.
Keep the following in mind as you configure the RestAPIEnrich gem:
  • To hide sensitive information like API keys and passwords, Databricks secrets can be used as shown below.
  • If the expected number of rows are very large, it’s better to provide await time in the advanced tab so you don’t overwhelm the source server or exceed any request limits.
  • For APIs which takes list of parameters as inputs, window functions like collect_list can be used before RestApiEnrich gem to reduce the number of API calls.

Reference pipeline configurations

To reference variables from your pipeline configs:
  • Use the following syntax: ${config_name}
  • You can also use partial strings, for example: foo_${config_name}bar

Example 1

Let’s try to fetch prices for few cryptocurrencies from Coin-API. We would be taking cryptocurrency and currency as input from DataFrame and pass url, headers as static values. Note that URL in this example is created using static base url and adding cryptocurrency and currency as inputs from DataFrame. Also, we would be using Databricks-secrets to pass headers as it requires API-key.

Example 2

Let’s take a more complex example, where all method, url, headers, params etc are passed as values from DataFrame columns.

Generated Code