Skip to main content
For AI agents: a documentation index is available at https://docs.parallel.ai/llms.txt. The full text of all docs is at https://docs.parallel.ai/llms-full.txt. You may also fetch any page as Markdown by appending .md to its URL or sending Accept: text/markdown.
This integration is ideal for data engineers who need to enrich large datasets with web intelligence directly in their Spark pipelines—without leaving SQL or building custom API integrations. Parallel provides SQL-native User Defined Functions (UDFs) for Apache Spark that enable data enrichment directly in your SQL queries. The UDFs process rows concurrently within each partition for optimal performance.
View the complete demo notebooks:

Features

  • SQL-Native: Use parallel_enrich() directly in Spark SQL queries
  • Concurrent Processing: All rows in each partition are processed concurrently using asyncio
  • Configurable Processors: Choose from lite-fast to ultra for speed vs thoroughness tradeoffs
  • Structured Output: Returns JSON that can be parsed with Spark’s from_json()

Installation

Setup

  1. Get your API key from Parallel
  2. Register the UDFs with your Spark session:

Configuration Options

Basic Usage

Once registered, use parallel_enrich() in any SQL query:
Output:

UDF Parameters

Parsing Results

The UDF returns JSON strings. Field names are converted to snake_case (e.g., “CEO name” → ceo_name). Use get_json_object() to extract individual fields:
Output:
Or use from_json() with a schema for structured parsing:
Output:

Including Basis/Citations

To include source citations in your enrichment results, set include_basis=True:
Output (truncated):
When enabled, each result includes a _basis field with citations:

Processor Selection

Choose a processor based on your speed vs thoroughness requirements. See Choose a Processor for detailed guidance and Pricing for cost information. Use the parallel_enrich_with_processor UDF to override per query:
Output:

Best Practices

The UDF processes all rows in a partition concurrently. For optimal performance:
  • Use repartition() to control partition sizes
  • Aim for 10-100 rows per partition for balanced concurrency
Failed enrichments return JSON with an error field:
Filter these in your downstream processing.
Concurrent processing respects Parallel’s rate limits. For large datasets, consider:
  • Reducing partition sizes
  • Using slower processors that have higher rate limits