databricks-dbsql

Generates and explains Databricks SQL for warehouses, AI functions, geospatial queries, and data modeling.

Updated Mar 24, 2026
One-click install
npx skills add https://github.com/AarushiShah/coding-agents-databricks-apps --skill databricks-dbsql-aarushishah
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: databricks-dbsql
Source: https://github.com/AarushiShah/coding-agents-databricks-apps/tree/main/.claude/skills/databricks-dbsql
Command: npx skills add https://github.com/AarushiShah/coding-agents-databricks-apps --skill databricks-dbsql-aarushishah

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing correct Databricks SQL requires knowing which features exist, which runtime versions support them, and which syntax applies to SQL warehouses versus clusters. This Skill provides accurate syntax, version requirements, and production-ready patterns for DBSQL so you avoid trial-and-error with unfamiliar functions. ## Core Features & Use Cases - SQL Scripting and Procedures: Write procedural SQL with BEGIN...END blocks, DECLARE variables, stored procedures with error handlers, recursive CTEs, and multi-statement transactions. - AI Functions in SQL: Use ai_query, ai_classify, ai_extract, ai_mask, ai_forecast, and vector_search to enrich data with LLMs directly from SQL, plus http_request for external API calls. - Geospatial and Collation Support: Apply 39 H3 indexing functions, 80+ ST spatial functions, and ICU collations for proximity search, spatial joins, and case-insensitive queries. - Use Case: A data engineer needs to classify 10,000 support tickets by category and sentiment. The Skill provides the exact ai_classify and ai_analyze_sentiment syntax, reminds them to use a serverless SQL warehouse, and suggests LIMIT during development to control costs. ## Quick Start Ask the agent to write a Databricks SQL query that classifies support tickets by category using ai_classify on a serverless SQL warehouse.

Frequently Asked Questions about databricks-dbsql

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

FAQPage Schema
How do I use AI functions like ai_query in Databricks SQL?

Call ai_query with an endpoint name and prompt string, optionally adding returnType, modelParameters, or responseFormat for structured output. AI functions require a serverless SQL warehouse and Databricks Runtime 15.1 or later; use LIMIT during development to control token costs.

How to create a stored procedure in Databricks SQL?

Use CREATE OR REPLACE PROCEDURE with LANGUAGE SQL, defining IN and OUT parameters and a BEGIN...END body. Stored procedures require Databricks Runtime 17.0+ and support DECLARE variables, IF/WHILE/FOR logic, and EXIT handlers for error handling.

Does Databricks SQL support materialized views?

Yes, CREATE MATERIALIZED VIEW is supported on Pro and Serverless SQL warehouses. You can add CLUSTER BY for Liquid Clustering and SCHEDULE EVERY for automatic refreshes, making them suitable for frequently computed aggregations.

What is the difference between H3 and ST functions in Databricks?

H3 functions index locations into hexagonal grid cells for fast pre-filtering and aggregation, while ST functions perform precise spatial operations like ST_Contains and ST_Distance on GEOMETRY and GEOGRAPHY types. Combining H3 pre-filtering with ST predicates gives the best spatial join performance.

How do I make string comparisons case-insensitive in Databricks SQL?

Apply the UTF8_LCASE or UNICODE_CI collation at the column, table, schema, or expression level using COLLATE. Collations require Databricks Runtime 16.1+, and STARTSWITH or ENDSWITH with UTF8_LCASE can run up to 10x faster than LOWER() workarounds.

Can Databricks SQL query external databases like PostgreSQL?

Yes, the remote_query table-valued function queries PostgreSQL, MySQL, SQL Server, Oracle, Snowflake, BigQuery, and others through Lakehouse Federation connections. It is read-only, requires a Unity Catalog connection with USE CONNECTION privilege, and supports filter and aggregate pushdown.