matlab-connect-databricks

Connect MATLAB to Databricks via Spark or JDBC for reading and writing data.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-connect-databricks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-connect-databricks
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/reporting-and-database-access/matlab-connect-databricks
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-connect-databricks

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Setting up MATLAB to work with Databricks involves choosing between Spark and JDBC paths, configuring authentication, matching Python and Java versions, and avoiding common pitfalls like pulling unfiltered large tables or building fragile JDBC URLs manually. This Skill guides the entire connection workflow so data moves correctly between MATLAB and Databricks.

Core Features & Use Cases

  • Dual Connection Paths: Create Spark sessions with getDatabricksSession() for server-side filtering of large tables, or JDBC connections with databricks.JDBCConnection and StandaloneJDBCConnection for SQL-based workflows via Database Toolbox.
  • Authentication Setup: Configure OauthU2M, OauthM2M, or PAT authentication through .databrickscfg profiles, environment variables, or token passthrough, including serverless compute and on-Databricks browser scenarios.
  • Data Operations: Read Unity Catalog tables and Volume files, filter and transform DataFrames server-side, and write results back using Spark DataFrames or JDBC sqlwrite with Simba driver optimization.
  • Use Case: An engineer needs to analyze millions of sensor readings stored in Unity Catalog. The Skill guides them to create a Spark session, filter rows server-side by date and temperature thresholds, and pull only the filtered results into a MATLAB table for analysis.

Quick Start

Ask your AI agent to connect MATLAB to your Databricks workspace and read a filtered subset of a Unity Catalog table into a MATLAB table.

Frequently Asked Questions about matlab-connect-databricks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect MATLAB to Databricks?

Use getDatabricksSession() for a Spark connection or databricks.JDBCConnection() for a JDBC connection through Database Toolbox. Run the package's setup script first to configure .databrickscfg and install the Databricks Connect library.

Should I use Spark or JDBC to read Databricks data in MATLAB?

Use Spark for large tables needing server-side filtering or DataFrame transformations, since only filtered results transfer locally. Use JDBC for SQL queries on small-to-medium datasets or when working with Database Toolbox functions like sqlread and fetch.

Can I connect MATLAB to Databricks without the interface package?

Yes, StandaloneJDBCConnection provides JDBC connectivity with only Database Toolbox and the Simba driver jar. Configure host, orgId, clusterId, and authentication in a JSON settings file, then access the connection through j.Connection.

Why does getDatabricksSession fail with a package not installed error?

This means MATLAB's pyenv does not point to the venv Python created during setup. Set pyenv to the venv interpreter path, but note that if Python is already loaded InProcess, a full MATLAB restart is required.

What authentication methods does Databricks JDBC support in MATLAB?

Supported methods are OauthU2M browser login, OauthM2M service principal credentials, PAT tokens, and token passthrough. Credentials resolve from constructor arguments, environment variables, .databrickscfg profiles, or databricks-settings.json in that order.

Why does OAuth browser login fail when MATLAB runs on Databricks?

The JDBC driver's OAuth flow cannot open a browser in browser-based MATLAB on a cluster. Use databricks.JDBCConnection with useDriverAuth=false for package-managed auth, or pass a passthroughAccessToken instead.