Execute SQL queries against Databricks using the DBSQL MCP server...
This skill enables SQL query execution against Databricks using the Databricks Managed MCP DBSQL server. It provides access to Unity Catalog tables, SQL warehouses, and supports both simple queries and complex analytics.
.vscode/mcp.jsonDATABRICKS_HOSTDATABRICKS_TOKENDATABRICKS_CATALOGDATABRICKS_SCHEMAThis skill uses the Databricks DBSQL MCP server which is automatically available when configured. The MCP server provides tools for:
SELECT *
FROM main.sales.customer_revenue
LIMIT 10;
SELECT
customer_id,
SUM(revenue) as total_revenue,
COUNT(*) as transaction_count
FROM main.sales.transactions
WHERE date >= '2025-01-01'
GROUP BY customer_id
ORDER BY total_revenue DESC
LIMIT 100;
SELECT
c.customer_id,
c.customer_name,
SUM(t.revenue) as total_revenue
FROM main.sales.customers c
INNER JOIN main.sales.transactions t
ON c.customer_id = t.customer_id
WHERE t.date >= CURRENT_DATE - INTERVAL 30 DAYS
GROUP BY c.customer_id, c.customer_name
ORDER BY total_revenue DESC;
CREATE OR REPLACE TABLE main.analytics.customer_summary AS
SELECT
customer_id,
COUNT(*) as order_count,
SUM(revenue) as total_revenue,
AVG(revenue) as avg_revenue,
MAX(date) as last_order_date
FROM main.sales.transactions
GROUP BY customer_id;
INSERT INTO main.sales.customer_revenue
SELECT
customer_id,
SUM(revenue) as revenue,
CURRENT_DATE() as calculation_date
FROM main.sales.transactions
WHERE date = CURRENT_DATE() - INTERVAL 1 DAY
GROUP BY customer_id;
SHOW SCHEMAS IN main;
SHOW TABLES IN main.sales;
DESCRIBE TABLE main.sales.customer_revenue;
SHOW TBLPROPERTIES main.sales.customer_revenue;
DESCRIBE DETAIL main.sales.customer_revenue;
catalog.schema.table formatLIMIT clause for exploratory queries-- Quick sample
SELECT * FROM main.sales.transactions LIMIT 5;
-- Row count
SELECT COUNT(*) FROM main.sales.transactions;
-- Date range
SELECT MIN(date), MAX(date) FROM main.sales.transactions;
-- Value distribution
SELECT column_name, COUNT(*)
FROM main.sales.transactions
GROUP BY column_name
ORDER BY COUNT(*) DESC
LIMIT 20;
-- Check for nulls
SELECT
COUNT(*) as total_rows,
COUNT(customer_id) as non_null_customer_id,
COUNT(revenue) as non_null_revenue
FROM main.sales.transactions;
-- Find duplicates
SELECT customer_id, transaction_id, COUNT(*)
FROM main.sales.transactions
GROUP BY customer_id, transaction_id
HAVING COUNT(*) > 1;
-- Check date ranges
SELECT
MIN(date) as earliest_date,
MAX(date) as latest_date,
DATEDIFF(MAX(date), MIN(date)) as date_span_days
FROM main.sales.transactions;
-- Daily aggregation
SELECT
DATE(timestamp) as date,
COUNT(*) as transaction_count,
SUM(revenue) as daily_revenue
FROM main.sales.transactions
GROUP BY DATE(timestamp)
ORDER BY date DESC;
-- Monthly trends
SELECT
DATE_TRUNC('month', date) as month,
SUM(revenue) as monthly_revenue,
COUNT(DISTINCT customer_id) as unique_customers
FROM main.sales.transactions
GROUP BY DATE_TRUNC('month', date)
ORDER BY month DESC;
When queries fail, check:
The Databricks DBSQL MCP server provides these capabilities automatically:
When using this skill, the MCP server handles the connection details. Simply focus on writing correct SQL queries.
Query results are typically returned as:
ANALYZE TABLE to update statistics