AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(databricks): query and load Unity Catalog tables, upload files to volumes and ask Genie from flows (#16750)
Kishan Parmarca90c9385383
diff --git a/bun.lock b/bun.lockindex 6aaf29b1431..0fd9194a4b4 100644--- a/bun.lock+++ b/bun.lock@@ -336,7 +336,7 @@},"packages/pieces/community/agentx": {"name": "@activepieces/piece-agentx",- "version": "0.1.7",+ "version": "0.1.8","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -571,7 +571,7 @@},"packages/pieces/community/amazon-s3": {"name": "@activepieces/piece-amazon-s3",- "version": "0.8.0",+ "version": "0.8.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -745,7 +745,7 @@},"packages/pieces/community/apitable": {"name": "@activepieces/piece-apitable",- "version": "0.5.0",+ "version": "0.5.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -903,7 +903,7 @@},"packages/pieces/community/autocalls": {"name": "@activepieces/piece-autocalls",- "version": "0.1.7",+ "version": "0.1.8","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -964,7 +964,7 @@},"packages/pieces/community/azure-ad": {"name": "@activepieces/piece-azure-ad",- "version": "0.3.2",+ "version": "0.3.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1036,7 +1036,7 @@},"packages/pieces/community/backblaze": {"name": "@activepieces/piece-backblaze",- "version": "0.1.7",+ "version": "0.1.8","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1103,7 +1103,7 @@},"packages/pieces/community/base44": {"name": "@activepieces/piece-base44",- "version": "0.1.8",+ "version": "0.1.9","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1181,7 +1181,7 @@},"packages/pieces/community/bexio": {"name": "@activepieces/piece-bexio",- "version": "0.2.1",+ "version": "0.2.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1463,7 +1463,7 @@},"packages/pieces/community/buffer": {"name": "@activepieces/piece-buffer",- "version": "0.1.2",+ "version": "0.1.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1807,7 +1807,7 @@},"packages/pieces/community/chatling": {"name": "@activepieces/piece-chatling",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1887,7 +1887,7 @@},"packages/pieces/community/circle": {"name": "@activepieces/piece-circle",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2043,7 +2043,7 @@},"packages/pieces/community/clockodo": {"name": "@activepieces/piece-clockodo",- "version": "0.2.8",+ "version": "0.2.9","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2084,7 +2084,7 @@},"packages/pieces/community/cloudinary": {"name": "@activepieces/piece-cloudinary",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2182,7 +2182,7 @@},"packages/pieces/community/comfyicu": {"name": "@activepieces/piece-comfyicu",- "version": "0.1.6",+ "version": "0.1.7","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2254,7 +2254,7 @@},"packages/pieces/community/contextual-ai": {"name": "@activepieces/piece-contextual-ai",- "version": "0.1.8",+ "version": "0.1.9","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2308,7 +2308,7 @@},"packages/pieces/community/copper": {"name": "@activepieces/piece-copper",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2377,7 +2377,7 @@},"packages/pieces/community/crisp": {"name": "@activepieces/piece-crisp",- "version": "0.2.1",+ "version": "0.2.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2391,7 +2391,7 @@},"packages/pieces/community/cryptolens": {"name": "@activepieces/piece-cryptolens",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2404,7 +2404,7 @@},"packages/pieces/community/cursor": {"name": "@activepieces/piece-cursor",- "version": "0.1.7",+ "version": "0.1.8","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2484,6 +2484,15 @@"tslib": "^2.3.0",},},+ "packages/pieces/community/databricks": {+ "name": "@activepieces/piece-databricks",+ "version": "0.0.1",+ "dependencies": {+ "@activepieces/pieces-common": "workspace:*",+ "@activepieces/pieces-framework": "workspace:*",+ "tslib": "2.6.2",+ },+ },"packages/pieces/community/datadog": {"name": "@activepieces/piece-datadog","version": "0.2.2",@@ -2695,7 +2704,7 @@},"packages/pieces/community/discord": {"name": "@activepieces/piece-discord",- "version": "0.8.0",+ "version": "0.8.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2836,7 +2845,7 @@},"packages/pieces/community/drupal": {"name": "@activepieces/piece-drupal",- "version": "1.1.11",+ "version": "1.1.12","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2920,7 +2929,7 @@},"packages/pieces/community/echowin": {"name": "@activepieces/piece-echowin",- "version": "0.1.7",+ "version": "0.1.8","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3006,7 +3015,7 @@},"packages/pieces/community/emailoctopus": {"name": "@activepieces/piece-emailoctopus",- "version": "0.2.1",+ "version": "0.3.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3124,7 +3133,7 @@},"packages/pieces/community/famulor": {"name": "@activepieces/piece-famulor",- "version": "0.2.5",+ "version": "0.2.6","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3194,7 +3203,7 @@},"packages/pieces/community/fellow": {"name": "@activepieces/piece-fellow",- "version": "0.2.1",+ "version": "0.2.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3342,7 +3351,7 @@},"packages/pieces/community/flow-parser": {"name": "@activepieces/piece-flow-parser",- "version": "0.1.8",+ "version": "0.1.9","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3426,7 +3435,7 @@},"packages/pieces/community/formio": {"name": "@activepieces/piece-formio",- "version": "0.1.3",+ "version": "0.1.4","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3479,7 +3488,7 @@},"packages/pieces/community/formstack": {"name": "@activepieces/piece-formstack",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3506,7 +3515,7 @@},"packages/pieces/community/fragment": {"name": "@activepieces/piece-fragment",- "version": "0.1.7",+ "version": "0.1.8","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3533,7 +3542,7 @@},"packages/pieces/community/free-agent": {"name": "@activepieces/piece-free-agent",- "version": "0.1.8",+ "version": "0.1.9","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3573,7 +3582,7 @@},"packages/pieces/community/freshservice": {"name": "@activepieces/piece-freshservice",- "version": "0.2.3",+ "version": "0.2.4","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3599,7 +3608,7 @@},"packages/pieces/community/front": {"name": "@activepieces/piece-front",- "version": "0.2.2",+ "version": "0.2.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3871,7 +3880,7 @@},"packages/pieces/community/google-calendar": {"name": "@activepieces/piece-google-calendar",- "version": "0.13.1",+ "version": "0.13.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3918,7 +3927,7 @@},"packages/pieces/community/google-docs": {"name": "@activepieces/piece-google-docs",- "version": "0.6.2",+ "version": "0.6.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3948,7 +3957,7 @@},"packages/pieces/community/google-drive": {"name": "@activepieces/piece-google-drive",- "version": "0.13.0",+ "version": "0.13.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3969,7 +3978,7 @@},"packages/pieces/community/google-forms": {"name": "@activepieces/piece-google-forms",- "version": "0.7.3",+ "version": "0.7.4","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4049,7 +4058,7 @@},"packages/pieces/community/google-sheets": {"name": "@activepieces/piece-google-sheets",- "version": "0.19.1",+ "version": "0.19.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4088,7 +4097,7 @@},"packages/pieces/community/google-tasks": {"name": "@activepieces/piece-google-tasks",- "version": "0.7.1",+ "version": "0.7.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4247,7 +4256,7 @@},"packages/pieces/community/griptape": {"name": "@activepieces/piece-griptape",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4302,7 +4311,7 @@},"packages/pieces/community/guidelite": {"name": "@activepieces/piece-guidelite",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4424,7 +4433,7 @@},"packages/pieces/community/heymarket-sms": {"name": "@activepieces/piece-heymarket-sms",- "version": "0.1.0",+ "version": "0.1.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4512,7 +4521,7 @@},"packages/pieces/community/hume-ai": {"name": "@activepieces/piece-hume-ai",- "version": "0.1.8",+ "version": "0.1.9","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4526,7 +4535,7 @@},"packages/pieces/community/hunter": {"name": "@activepieces/piece-hunter",- "version": "0.1.7",+ "version": "0.1.8","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4593,7 +4602,7 @@},"packages/pieces/community/imap": {"name": "@activepieces/piece-imap",- "version": "0.6.2",+ "version": "0.6.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4676,7 +4685,7 @@},"packages/pieces/community/instabase": {"name": "@activepieces/piece-instabase",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4704,7 +4713,7 @@},"packages/pieces/community/instantly-ai": {"name": "@activepieces/piece-instantly-ai",- "version": "0.2.1",+ "version": "0.2.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4997,7 +5006,7 @@},"packages/pieces/community/klaviyo": {"name": "@activepieces/piece-klaviyo",- "version": "0.2.1",+ "version": "0.2.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -5130,7 +5139,7 @@},"packages/pieces/community/lead-connector": {"name": "@activepieces/piece-lead-connector",- "version": "0.4.1",+ "version": "0.4.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -5159,7 +5168,7 @@},"packages/pieces/community/leexi": {"name": "@activepieces/piece-leexi",- "version": "0.2.1",+ "version": "0.2.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -5213,7 +5222,7 @@},"packages/pieces/community/lets-calendar": {"name": "@activepieces/piece-lets-calendar",- "version": "0.1.0",+ "version": "0.1.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -5868,7 +5877,7 @@},"packages/pieces/community/microsoft-365-people": {"name": "@activepieces/piece-microsoft-365-people",- "version": "0.3.1",+ "version": "0.3.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -5884,7 +5893,7 @@},"packages/pieces/community/microsoft-365-planner": {"name": "@activepieces/piece-microsoft-365-planner",- "version": "0.4.0",+ "version": "0.4.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -5916,7 +5925,7 @@},"packages/pieces/community/microsoft-dynamics-365-business-central": {"name": "@activepieces/piece-microsoft-dynamics-365-business-central",- "version": "0.3.0",+ "version": "0.3.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -5943,7 +5952,7 @@},"packages/pieces/community/microsoft-excel-365": {"name": "@activepieces/piece-microsoft-excel-365",- "version": "0.8.3",+ "version": "0.8.4","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -5978,7 +5987,7 @@},"packages/pieces/community/microsoft-onenote": {"name": "@activepieces/piece-microsoft-onenote",- "version": "0.4.2",+ "version": "0.4.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -5993,7 +6002,7 @@},"packages/pieces/community/microsoft-outlook": {"name": "@activepieces/piece-microsoft-outlook",- "version": "0.7.3",+ "version": "0.7.4","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -6038,7 +6047,7 @@},"packages/pieces/community/microsoft-sharepoint": {"name": "@activepieces/piece-microsoft-sharepoint",- "version": "0.4.2",+ "version": "0.4.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -6070,7 +6079,7 @@},"packages/pieces/community/microsoft-teams": {"name": "@activepieces/piece-microsoft-teams",- "version": "0.7.3",+ "version": "0.7.4","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -6101,7 +6110,7 @@},"packages/pieces/community/microsoft-todo": {"name": "@activepieces/piece-microsoft-todo",- "version": "0.5.1",+ "version": "0.5.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -6223,7 +6232,7 @@},"packages/pieces/community/mollie": {"name": "@activepieces/piece-mollie",- "version": "0.1.6",+ "version": "0.1.7","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -6294,7 +6303,7 @@},"packages/pieces/community/motion": {"name": "@activepieces/piece-motion",- "version": "0.2.1",+ "version": "0.2.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -6500,7 +6509,7 @@},"packages/pieces/community/ninox": {"name": "@activepieces/piece-ninox",- "version": "0.2.1",+ "version": "0.2.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -6528,7 +6537,7 @@},"packages/pieces/community/notion": {"name": "@activepieces/piece-notion",- "version": "0.8.1",+ "version": "0.8.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -6786,7 +6795,7 @@},"packages/pieces/community/oracle-database": {"name": "@activepieces/piece-oracle-database",- "version": "0.1.15",+ "version": "0.1.16","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -6920,7 +6929,7 @@},"packages/pieces/community/parseur": {"name": "@activepieces/piece-parseur",- "version": "0.2.2",+ "version": "0.2.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7154,7 +7163,7 @@},"packages/pieces/community/pinterest": {"name": "@activepieces/piece-pinterest",- "version": "0.2.2",+ "version": "0.2.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7292,7 +7301,7 @@},"packages/pieces/community/postgres": {"name": "@activepieces/piece-postgres",- "version": "0.5.0",+ "version": "0.5.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7377,7 +7386,7 @@},"packages/pieces/community/presentation": {"name": "@activepieces/piece-presentation",- "version": "0.3.0",+ "version": "0.3.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7545,7 +7554,7 @@},"packages/pieces/community/qdrant": {"name": "@activepieces/piece-qdrant",- "version": "0.3.7",+ "version": "0.4.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7586,7 +7595,7 @@},"packages/pieces/community/quickbase": {"name": "@activepieces/piece-quickbase",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7681,7 +7690,7 @@},"packages/pieces/community/rabbitmq": {"name": "@activepieces/piece-rabbitmq",- "version": "0.1.7",+ "version": "0.1.8","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -8001,7 +8010,7 @@},"packages/pieces/community/rss": {"name": "@activepieces/piece-rss",- "version": "0.7.0",+ "version": "0.7.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -8084,7 +8093,7 @@},"packages/pieces/community/salesforce": {"name": "@activepieces/piece-salesforce",- "version": "0.10.0",+ "version": "0.10.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -8375,7 +8384,7 @@},"packages/pieces/community/service-now": {"name": "@activepieces/piece-service-now",- "version": "0.3.1",+ "version": "0.3.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -8417,7 +8426,7 @@},"packages/pieces/community/shippo": {"name": "@activepieces/piece-shippo",- "version": "0.1.7",+ "version": "0.1.8","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -8431,7 +8440,7 @@},"packages/pieces/community/shopify": {"name": "@activepieces/piece-shopify",- "version": "0.11.1",+ "version": "0.11.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -8542,7 +8551,7 @@},"packages/pieces/community/sitespeakai": {"name": "@activepieces/piece-sitespeakai",- "version": "0.1.6",+ "version": "0.1.7","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -8556,7 +8565,7 @@},"packages/pieces/community/skyprep": {"name": "@activepieces/piece-skyprep",- "version": "0.0.9",+ "version": "0.0.10","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -8694,7 +8703,7 @@},"packages/pieces/community/smoove": {"name": "@activepieces/piece-smoove",- "version": "0.1.7",+ "version": "0.1.8","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -8958,7 +8967,7 @@},"packages/pieces/community/surrealdb": {"name": "@activepieces/piece-surrealdb",- "version": "0.1.7",+ "version": "0.1.8","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9038,7 +9047,7 @@},"packages/pieces/community/tableau": {"name": "@activepieces/piece-tableau",- "version": "0.1.6",+ "version": "0.1.7","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9215,7 +9224,7 @@},"packages/pieces/community/tenzo": {"name": "@activepieces/piece-tenzo",- "version": "0.0.8",+ "version": "0.0.9","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9281,7 +9290,7 @@},"packages/pieces/community/tidycal": {"name": "@activepieces/piece-tidycal",- "version": "0.3.1",+ "version": "0.3.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9295,7 +9304,7 @@},"packages/pieces/community/time-ops": {"name": "@activepieces/piece-time-ops",- "version": "0.1.0",+ "version": "0.1.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9308,7 +9317,7 @@},"packages/pieces/community/timelines-ai": {"name": "@activepieces/piece-timelines-ai",- "version": "0.2.2",+ "version": "0.2.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9348,7 +9357,7 @@},"packages/pieces/community/todoist": {"name": "@activepieces/piece-todoist",- "version": "0.6.1",+ "version": "0.6.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9435,7 +9444,7 @@},"packages/pieces/community/twenty": {"name": "@activepieces/piece-twenty",- "version": "0.1.1",+ "version": "0.2.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9449,7 +9458,7 @@},"packages/pieces/community/twilio": {"name": "@activepieces/piece-twilio",- "version": "0.7.0",+ "version": "0.7.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9475,7 +9484,7 @@},"packages/pieces/community/twitch": {"name": "@activepieces/piece-twitch",- "version": "0.1.0",+ "version": "0.1.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9757,7 +9766,7 @@},"packages/pieces/community/vimeo": {"name": "@activepieces/piece-vimeo",- "version": "0.2.1",+ "version": "0.2.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9799,7 +9808,7 @@},"packages/pieces/community/voipstudio": {"name": "@activepieces/piece-voipstudio",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9897,7 +9906,7 @@},"packages/pieces/community/wealthbox": {"name": "@activepieces/piece-wealthbox",- "version": "0.1.6",+ "version": "0.1.7","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9937,7 +9946,7 @@},"packages/pieces/community/webling": {"name": "@activepieces/piece-webling",- "version": "0.1.6",+ "version": "0.1.7","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10274,7 +10283,7 @@},"packages/pieces/community/youtube": {"name": "@activepieces/piece-youtube",- "version": "0.9.1",+ "version": "0.9.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10305,7 +10314,7 @@},"packages/pieces/community/zendesk": {"name": "@activepieces/piece-zendesk",- "version": "0.5.1",+ "version": "0.5.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10320,7 +10329,7 @@},"packages/pieces/community/zendesk-sell": {"name": "@activepieces/piece-zendesk-sell",- "version": "0.2.1",+ "version": "0.2.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10387,7 +10396,7 @@},"packages/pieces/community/zoho-campaigns": {"name": "@activepieces/piece-zoho-campaigns",- "version": "0.2.2",+ "version": "0.3.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10430,7 +10439,7 @@},"packages/pieces/community/zoho-invoice": {"name": "@activepieces/piece-zoho-invoice",- "version": "0.2.2",+ "version": "0.3.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10444,7 +10453,7 @@},"packages/pieces/community/zoho-mail": {"name": "@activepieces/piece-zoho-mail",- "version": "0.2.2",+ "version": "0.2.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -11768,6 +11777,8 @@"@activepieces/piece-data-summarizer": ["@activepieces/piece-data-summarizer@workspace:packages/pieces/core/data-summarizer"],+ "@activepieces/piece-databricks": ["@activepieces/piece-databricks@workspace:packages/pieces/community/databricks"],+"@activepieces/piece-datadog": ["@activepieces/piece-datadog@workspace:packages/pieces/community/datadog"],"@activepieces/piece-dataforb2b": ["@activepieces/piece-dataforb2b@workspace:packages/pieces/community/dataforb2b"],diff --git a/packages/pieces/community/databricks/.eslintrc.json b/packages/pieces/community/databricks/.eslintrc.jsonnew file mode 100644index 00000000000..01f1c80f85a--- /dev/null+++ b/packages/pieces/community/databricks/.eslintrc.json@@ -0,0 +1,47 @@+{+ "extends": [+ "../../../../.eslintrc.base.json"+ ],+ "ignorePatterns": [+ "!**/*"+ ],+ "overrides": [+ {+ "files": [+ "*.ts",+ "*.tsx",+ "*.js",+ "*.jsx"+ ],+ "rules": {}+ },+ {+ "files": [+ "*.ts",+ "*.tsx"+ ],+ "rules": {+ "no-restricted-imports": [+ "error",+ {+ "patterns": [+ "lodash",+ "lodash/*",+ "@activepieces/core-*",+ "@activepieces/server*",+ "@activepieces/engine",+ "@activepieces/shared"+ ]+ }+ ]+ }+ },+ {+ "files": [+ "*.js",+ "*.jsx"+ ],+ "rules": {}+ }+ ]+}diff --git a/packages/pieces/community/databricks/package.json b/packages/pieces/community/databricks/package.jsonnew file mode 100644index 00000000000..ca589a14619--- /dev/null+++ b/packages/pieces/community/databricks/package.json@@ -0,0 +1,15 @@+{+ "name": "@activepieces/piece-databricks",+ "version": "0.0.1",+ "main": "./dist/src/index.js",+ "types": "./dist/src/index.d.ts",+ "scripts": {+ "build": "tsc -p tsconfig.lib.json && cp package.json dist/",+ "lint": "eslint 'src/**/*.ts'"+ },+ "dependencies": {+ "@activepieces/pieces-common": "workspace:*",+ "@activepieces/pieces-framework": "workspace:*",+ "tslib": "2.6.2"+ }+}diff --git a/packages/pieces/community/databricks/src/i18n/translation.json b/packages/pieces/community/databricks/src/i18n/translation.jsonnew file mode 100644index 00000000000..65e1ec8cda6--- /dev/null+++ b/packages/pieces/community/databricks/src/i18n/translation.json@@ -0,0 +1,104 @@+{+ "Data and AI platform: query and load Unity Catalog tables, upload files to volumes and ask Genie questions.": "Data and AI platform: query and load Unity Catalog tables, upload files to volumes and ask Genie questions.",+ "Workspace URL": "Workspace URL",+ "Client ID": "Client ID",+ "Client Secret": "Client Secret",+ "Your Databricks workspace URL, e.g. https://dbc-a1b2c3d4-e5f6.cloud.databricks.com or https://adb-1234567890123456.7.azuredatabricks.net": "Your Databricks workspace URL, e.g. https://dbc-a1b2c3d4-e5f6.cloud.databricks.com or https://adb-1234567890123456.7.azuredatabricks.net",+ "The service principal's client ID (also called application ID), e.g. 6b1d5c2e-0a4f-4c3b-9f1e-2d7a8b9c0d1e.": "The service principal's client ID (also called application ID), e.g. 6b1d5c2e-0a4f-4c3b-9f1e-2d7a8b9c0d1e.",+ "The OAuth secret generated on the service principal's Secrets tab.": "The OAuth secret generated on the service principal's Secrets tab.",+ "Connect with a Databricks service principal (OAuth machine-to-machine). Activepieces exchanges the client ID and secret for short-lived access tokens automatically.\n\n1. In your Databricks workspace, open **Settings → Identity and access → Service principals** and add (or pick) a service principal.\n2. On the service principal's **Secrets** tab, click **Generate secret** and copy the **Client ID** and **Secret**.\n3. Grant the service principal **Can use** on the SQL warehouse, and the Unity Catalog privileges": "Connect with a Databricks service principal (OAuth machine-to-machine). Activepieces exchanges the client ID and secret for short-lived access tokens automatically.\n\n1. In your Databricks workspace, open **Settings → Identity and access → Service principals** and add (or pick) a service principal.\n2. On the service principal's **Secrets** tab, click **Generate secret** and copy the **Client ID** and **Secret**.\n3. Grant the service principal **Can use** on the SQL warehouse, and the Unity Catalog privileges it needs (for example `USE CATALOG`, `USE SCHEMA`, `SELECT`, `MODIFY`, `READ VOLUME`, `WRITE VOLUME`). For Genie, give it **Can run** on the Genie space.\n4. Copy your workspace URL from the browser address bar, e.g. `https://dbc-a1b2c3d4-e5f6.cloud.databricks.com`.",+ "Insert Row": "Insert Row",+ "Insert Multiple Rows": "Insert Multiple Rows",+ "Update Rows": "Update Rows",+ "Upsert Row": "Upsert Row",+ "Find Rows": "Find Rows",+ "Run SQL Query": "Run SQL Query",+ "Upload File to Volume": "Upload File to Volume",+ "Ask Genie": "Ask Genie",+ "Custom API Call": "Custom API Call",+ "Adds one row to a Unity Catalog table.": "Adds one row to a Unity Catalog table.",+ "Adds many rows to a Unity Catalog table in one statement.": "Adds many rows to a Unity Catalog table in one statement.",+ "Updates the rows of a Unity Catalog table where a column matches a value.": "Updates the rows of a Unity Catalog table where a column matches a value.",+ "Updates the row with a matching key, or inserts it if no row matches (MERGE).": "Updates the row with a matching key, or inserts it if no row matches (MERGE).",+ "Finds rows in a Unity Catalog table where a column matches a value.": "Finds rows in a Unity Catalog table where a column matches a value.",+ "Runs any SQL statement on a SQL warehouse and returns the result rows.": "Runs any SQL statement on a SQL warehouse and returns the result rows.",+ "Uploads a file to a Unity Catalog volume and, optionally, loads it into a table with COPY INTO.": "Uploads a file to a Unity Catalog volume and, optionally, loads it into a table with COPY INTO.",+ "Asks a Genie space a question in plain language and returns the answer and query results.": "Asks a Genie space a question in plain language and returns the answer and query results.",+ "Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",+ "SQL Warehouse": "SQL Warehouse",+ "Catalog": "Catalog",+ "Schema": "Schema",+ "Table": "Table",+ "Values": "Values",+ "Rows": "Rows",+ "Match Column": "Match Column",+ "Match Value": "Match Value",+ "New Values": "New Values",+ "Key Column": "Key Column",+ "Filter Column": "Filter Column",+ "Filter Value": "Filter Value",+ "Limit": "Limit",+ "SQL Query": "SQL Query",+ "Parameters": "Parameters",+ "Volume": "Volume",+ "File": "File",+ "Folder": "Folder",+ "Load into Table": "Load into Table",+ "File Format": "File Format",+ "Add New Columns": "Add New Columns",+ "Genie Space": "Genie Space",+ "Question": "Question",+ "Conversation ID": "Conversation ID",+ "Method": "Method",+ "Headers": "Headers",+ "Query Parameters": "Query Parameters",+ "Body Type": "Body Type",+ "Body": "Body",+ "Response is Binary": "Response is Binary",+ "Return Error as Output": "Return Error as Output",+ "Timeout": "Timeout",+ "Follow redirects": "Follow redirects",+ "The SQL warehouse that runs the statement. The service principal needs \"Can use\" permission on it.": "The SQL warehouse that runs the statement. The service principal needs \"Can use\" permission on it.",+ "The Unity Catalog catalog.": "The Unity Catalog catalog.",+ "The schema inside the selected catalog.": "The schema inside the selected catalog.",+ "The table inside the selected schema.": "The table inside the selected schema.",+ "One field per table column. Leave a field empty to skip that column.": "One field per table column. Leave a field empty to skip that column.",+ "One item per row. Leave a field empty to insert NULL.": "One item per row. Leave a field empty to insert NULL.",+ "Rows whose value in this column equals Match Value are updated.": "Rows whose value in this column equals Match Value are updated.",+ "The value to look for in the match column, e.g. 1042 or [email protected].": "The value to look for in the match column, e.g. 1042 or [email protected].",+ "Fill in only the columns to change. Empty fields are left as they are.": "Fill in only the columns to change. Empty fields are left as they are.",+ "The column that identifies a row, e.g. id or email. A row with the same value is updated; otherwise a new row is inserted.": "The column that identifies a row, e.g. id or email. A row with the same value is updated; otherwise a new row is inserted.",+ "One field per table column. The key column must be filled in. Empty fields are not changed on update and inserted as NULL.": "One field per table column. The key column must be filled in. Empty fields are not changed on update and inserted as NULL.",+ "Only return rows whose value in this column equals Filter Value. Leave empty to return the first rows of the table.": "Only return rows whose value in this column equals Filter Value. Leave empty to return the first rows of the table.",+ "The value to match in the filter column, e.g. 1042 or [email protected].": "The value to match in the filter column, e.g. 1042 or [email protected].",+ "Maximum number of rows to return (1-10000). Defaults to 100.": "Maximum number of rows to return (1-10000). Defaults to 100.",+ "The SQL statement to run. Use fully qualified table names and :name markers for values, e.g. SELECT * FROM main.sales.orders WHERE status = :status LIMIT 100": "The SQL statement to run. Use fully qualified table names and :name markers for values, e.g. SELECT * FROM main.sales.orders WHERE status = :status LIMIT 100",+ "Values for the :name markers in the query, e.g. status → shipped. Values are passed as strings; cast in SQL when needed, e.g. CAST(:amount AS DECIMAL(10,2)).": "Values for the :name markers in the query, e.g. status → shipped. Values are passed as strings; cast in SQL when needed, e.g. CAST(:amount AS DECIMAL(10,2)).",+ "The Unity Catalog volume the file is uploaded to, inside the selected schema.": "The Unity Catalog volume the file is uploaded to, inside the selected schema.",+ "The file to upload, e.g. a CSV or JSON file from an FTP, email or HTTP step.": "The file to upload, e.g. a CSV or JSON file from an FTP, email or HTTP step.",+ "Optional folder inside the volume, e.g. imports/orders. It is created if it does not exist.": "Optional folder inside the volume, e.g. imports/orders. It is created if it does not exist.",+ "Optional. A table in the same catalog and schema to load the file into with COPY INTO. Leave empty to only upload the file.": "Optional. A table in the same catalog and schema to load the file into with COPY INTO. Leave empty to only upload the file.",+ "The SQL warehouse that runs COPY INTO. Required when Load into Table is set.": "The SQL warehouse that runs COPY INTO. Required when Load into Table is set.",+ "How the file is read when it is loaded into the table.": "How the file is read when it is loaded into the table.",+ "When the file has columns the table does not, add them to the table instead of failing.": "When the file has columns the table does not, add them to the table instead of failing.",+ "The Genie space to ask. The service principal needs \"Can run\" permission on it.": "The Genie space to ask. The service principal needs \"Can run\" permission on it.",+ "The question to ask, e.g. \"What were the top 5 products by revenue last month?\"": "The question to ask, e.g. \"What were the top 5 products by revenue last month?\"",+ "Optional. The Conversation ID from an earlier Ask Genie step, to ask a follow-up question in the same conversation.": "Optional. The Conversation ID from an earlier Ask Genie step, to ask a follow-up question in the same conversation.",+ "Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",+ "Appended to the URL as ?key=value.": "Appended to the URL as ?key=value.",+ "Enable for files like PDFs, images, etc.": "Enable for files like PDFs, images, etc.",+ "On a failed request, output the error instead of failing the step.": "On a failed request, output the error instead of failing the step.",+ "Seconds to wait for a response. Empty: up to the flow limit (10 min).": "Seconds to wait for a response. Empty: up to the flow limit (10 min).",+ "Follow 3xx redirects instead of returning them as the response.": "Follow 3xx redirects instead of returning them as the response.",+ "CSV (first row is the header)": "CSV (first row is the header)",+ "JSON (one object per line)": "JSON (one object per line)",+ "JSON (an array of objects, or one object over several lines)": "JSON (an array of objects, or one object over several lines)",+ "GET": "GET",+ "POST": "POST",+ "PATCH": "PATCH",+ "PUT": "PUT",+ "DELETE": "DELETE",+ "HEAD": "HEAD",+ "Request": "Request",+ "Data to send": "Data to send"+}diff --git a/packages/pieces/community/databricks/src/index.ts b/packages/pieces/community/databricks/src/index.tsnew file mode 100644index 00000000000..c45013e8e58--- /dev/null+++ b/packages/pieces/community/databricks/src/index.ts@@ -0,0 +1,54 @@+import { createCustomApiCallAction } from '@activepieces/pieces-common';+import { createPiece, PieceCategory } from '@activepieces/pieces-framework';++import { askGenieAction } from './lib/actions/ask-genie';+import { findRowsAction } from './lib/actions/find-rows';+import { insertRowAction } from './lib/actions/insert-row';+import { insertRowsAction } from './lib/actions/insert-rows';+import { runQueryAction } from './lib/actions/run-query';+import { updateRowsAction } from './lib/actions/update-rows';+import { uploadFileToVolumeAction } from './lib/actions/upload-file-to-volume';+import { upsertRowAction } from './lib/actions/upsert-row';+import { databricksAuth } from './lib/auth';+import { databricksClient } from './lib/common/client';++export const databricks = createPiece({+ displayName: 'Databricks',+ description:+ 'Data and AI platform: query and load Unity Catalog tables, upload files to volumes and ask Genie questions.',+ minimumSupportedRelease: '0.86.0',+ logoUrl: 'https://cdn.activepieces.com/pieces/databricks.png',+ categories: [+ PieceCategory.DEVELOPER_TOOLS,+ PieceCategory.BUSINESS_INTELLIGENCE,+ ],+ auth: databricksAuth,+ authors: ['kishanprmr'],+ actions: [+ insertRowAction,+ insertRowsAction,+ updateRowsAction,+ upsertRowAction,+ findRowsAction,+ runQueryAction,+ uploadFileToVolumeAction,+ askGenieAction,+ createCustomApiCallAction({+ auth: databricksAuth,+ baseUrl: (auth) => (auth ? databricksClient.baseUrl({ auth }) : ''),+ authMapping: async (auth, propsValue) => {+ const url = propsValue['url']?.['url'];+ if (+ typeof url === 'string' &&+ !databricksClient.isWorkspaceUrl({ auth, url })+ ) {+ throw new Error(+ 'Custom API Call only sends your Databricks credentials to the connected workspace. Use a path such as /api/2.0/clusters/list, or a URL on your workspace.'+ );+ }+ return { Authorization: `Bearer ${auth.access_token}` };+ },+ }),+ ],+ triggers: [],+});diff --git a/packages/pieces/community/databricks/src/lib/actions/ask-genie.ts b/packages/pieces/community/databricks/src/lib/actions/ask-genie.tsnew file mode 100644index 00000000000..bf8c0ac6e3d--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/actions/ask-genie.ts@@ -0,0 +1,46 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { databricksAuth } from '../auth';+import { databricksApi } from '../common/api';+import { databricksProps } from '../common/props';+import { askGenieOutputSchema } from '../output-schemas';++export const askGenieAction = createAction({+ auth: databricksAuth,+ name: 'ask_genie',+ classification: 'WRITE',+ displayName: 'Ask Genie',+ description:+ 'Asks a Genie space a question in plain language and returns the answer and query results.',+ audience: 'both',+ aiMetadata: {+ description:+ "Ask a Databricks AI/BI Genie space a natural-language question about its data; returns Genie's text answer, the SQL it generated and the result rows. Pass the returned conversation ID to ask a follow-up in the same conversation. Use Run SQL Query instead when you already know the SQL. Each call adds a message to the conversation.",+ idempotent: false,+ },+ props: {+ genieSpaceId: databricksProps.genieSpaceId({ required: true }),+ question: Property.LongText({+ displayName: 'Question',+ description:+ 'The question to ask, e.g. "What were the top 5 products by revenue last month?"',+ required: true,+ }),+ conversationId: Property.ShortText({+ displayName: 'Conversation ID',+ description:+ 'Optional. The Conversation ID from an earlier Ask Genie step, to ask a follow-up question in the same conversation.',+ required: false,+ }),+ },+ outputSchema: askGenieOutputSchema,+ async run(context) {+ const { genieSpaceId, question, conversationId } = context.propsValue;+ return await databricksApi.askGenie({+ auth: context.auth,+ spaceId: genieSpaceId,+ question,+ conversationId: conversationId || undefined,+ });+ },+});diff --git a/packages/pieces/community/databricks/src/lib/actions/find-rows.ts b/packages/pieces/community/databricks/src/lib/actions/find-rows.tsnew file mode 100644index 00000000000..7a1e5ffdeec--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/actions/find-rows.ts@@ -0,0 +1,98 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { databricksAuth } from '../auth';+import { databricksApi } from '../common/api';+import { databricksProps } from '../common/props';+import { databricksUtils } from '../common/utils';+import { queryResultOutputSchema } from '../output-schemas';++export const findRowsAction = createAction({+ auth: databricksAuth,+ name: 'find_rows',+ classification: 'SEARCH',+ displayName: 'Find Rows',+ description:+ 'Finds rows in a Unity Catalog table where a column matches a value.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Return rows from a Databricks Unity Catalog table whose column equals a value, or the first rows of the table when no filter is set. For joins, aggregates or other conditions use Run SQL Query. Read-only and safe to retry.',+ idempotent: true,+ },+ props: {+ warehouseId: databricksProps.warehouseId({ required: true }),+ catalogName: databricksProps.catalogName({ required: true }),+ schemaName: databricksProps.schemaName({ required: true }),+ tableName: databricksProps.tableName({ required: true }),+ columnName: databricksProps.columnName({+ required: false,+ displayName: 'Filter Column',+ description:+ 'Only return rows whose value in this column equals Filter Value. Leave empty to return the first rows of the table.',+ }),+ filterValue: Property.ShortText({+ displayName: 'Filter Value',+ description:+ 'The value to match in the filter column, e.g. 1042 or [email protected].',+ required: false,+ }),+ limit: Property.Number({+ displayName: 'Limit',+ description:+ 'Maximum number of rows to return (1-10000). Defaults to 100.',+ required: false,+ defaultValue: 100,+ }),+ },+ outputSchema: queryResultOutputSchema,+ async run(context) {+ const {+ warehouseId,+ catalogName,+ schemaName,+ tableName,+ columnName,+ filterValue,+ limit,+ } = context.propsValue;+ const rowLimit = Math.min(Math.max(Math.floor(limit ?? 100), 1), 10000);+ const from = `SELECT * FROM ${databricksUtils.tableRef({+ catalogName,+ schemaName,+ tableName,+ })}`;+ if (!columnName) {+ return await databricksApi.executeStatement({+ auth: context.auth,+ warehouseId,+ statement: `${from} LIMIT ${rowLimit}`,+ });+ }+ if (filterValue === undefined || filterValue === '') {+ throw new Error(+ 'Enter a Filter Value, or clear Filter Column to return the first rows.'+ );+ }+ const table = await databricksApi.getTable({+ auth: context.auth,+ catalogName,+ schemaName,+ tableName,+ });+ const column = databricksUtils.findColumn({+ columns: table.columns ?? [],+ name: columnName,+ });+ return await databricksApi.executeStatement({+ auth: context.auth,+ warehouseId,+ statement: `${from} WHERE ${databricksUtils.quoteIdentifier({+ name: column.name,+ })} = ${databricksUtils.convertToColumnType({+ column,+ expression: ':value',+ })} LIMIT ${rowLimit}`,+ parameters: [{ name: 'value', value: filterValue }],+ });+ },+});diff --git a/packages/pieces/community/databricks/src/lib/actions/insert-row.ts b/packages/pieces/community/databricks/src/lib/actions/insert-row.tsnew file mode 100644index 00000000000..3e3f79edb19--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/actions/insert-row.ts@@ -0,0 +1,56 @@+import { createAction } from '@activepieces/pieces-framework';++import { databricksAuth } from '../auth';+import { databricksApi } from '../common/api';+import { databricksProps } from '../common/props';+import { databricksUtils } from '../common/utils';+import { insertResultOutputSchema } from '../output-schemas';++export const insertRowAction = createAction({+ auth: databricksAuth,+ name: 'insert_row',+ classification: 'WRITE',+ displayName: 'Insert Row',+ description: 'Adds one row to a Unity Catalog table.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Insert a single row into a Databricks Unity Catalog table, filling one value per column. For many rows at once use Insert Multiple Rows; to insert-or-update by a key use Upsert Row. Each call adds a new row, so retries duplicate.',+ idempotent: false,+ },+ props: {+ warehouseId: databricksProps.warehouseId({ required: true }),+ catalogName: databricksProps.catalogName({ required: true }),+ schemaName: databricksProps.schemaName({ required: true }),+ tableName: databricksProps.tableName({ required: true }),+ rowFields: databricksProps.rowFields({ required: true }),+ },+ outputSchema: insertResultOutputSchema,+ async run(context) {+ const { warehouseId, catalogName, schemaName, tableName, rowFields } =+ context.propsValue;+ const table = await databricksApi.getTable({+ auth: context.auth,+ catalogName,+ schemaName,+ tableName,+ });+ const source = databricksUtils.buildRowSource({+ columns: table.columns ?? [],+ rows: [databricksUtils.compactRow({ row: rowFields ?? {} })],+ });+ const columnList = source.columnNames+ .map((name) => databricksUtils.quoteIdentifier({ name }))+ .join(', ');+ return await databricksApi.executeWriteStatement({+ auth: context.auth,+ warehouseId,+ statement: `INSERT INTO ${databricksUtils.tableRef({+ catalogName,+ schemaName,+ tableName,+ })} (${columnList}) ${source.sql}`,+ parameters: source.parameters,+ });+ },+});diff --git a/packages/pieces/community/databricks/src/lib/actions/insert-rows.ts b/packages/pieces/community/databricks/src/lib/actions/insert-rows.tsnew file mode 100644index 00000000000..f4ba7ddab44--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/actions/insert-rows.ts@@ -0,0 +1,68 @@+import { createAction } from '@activepieces/pieces-framework';++import { databricksAuth } from '../auth';+import { databricksApi } from '../common/api';+import { databricksProps } from '../common/props';+import { databricksUtils } from '../common/utils';+import { insertResultOutputSchema } from '../output-schemas';++export const insertRowsAction = createAction({+ auth: databricksAuth,+ name: 'insert_rows',+ classification: 'WRITE',+ displayName: 'Insert Multiple Rows',+ description: 'Adds many rows to a Unity Catalog table in one statement.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Insert a batch of rows into a Databricks Unity Catalog table in a single atomic INSERT. Pass rows as an array of objects keyed by column name; missing or empty fields become NULL. For files (CSV/JSON) use Upload File to Volume with a target table instead. Each call adds new rows, so retries duplicate.',+ idempotent: false,+ },+ props: {+ warehouseId: databricksProps.warehouseId({ required: true }),+ catalogName: databricksProps.catalogName({ required: true }),+ schemaName: databricksProps.schemaName({ required: true }),+ tableName: databricksProps.tableName({ required: true }),+ batch: databricksProps.rowList({ required: true }),+ },+ outputSchema: insertResultOutputSchema,+ async run(context) {+ const { warehouseId, catalogName, schemaName, tableName, batch } =+ context.propsValue;+ const rows = batch?.['rows'];+ const rowList = Array.isArray(rows) ? rows : [rows];+ if (rows === undefined || rows === null || rowList.length === 0) {+ throw new Error('Rows must contain at least one row.');+ }+ const table = await databricksApi.getTable({+ auth: context.auth,+ catalogName,+ schemaName,+ tableName,+ });+ const source = databricksUtils.buildRowSource({+ columns: table.columns ?? [],+ rows: rowList.map((row) => {+ if (row === null || typeof row !== 'object' || Array.isArray(row)) {+ throw new Error(+ 'Each row must be a JSON object keyed by column name.'+ );+ }+ return databricksUtils.compactRow({ row: Object.fromEntries(Object.entries(row)) });+ }),+ });+ const columnList = source.columnNames+ .map((name) => databricksUtils.quoteIdentifier({ name }))+ .join(', ');+ return await databricksApi.executeWriteStatement({+ auth: context.auth,+ warehouseId,+ statement: `INSERT INTO ${databricksUtils.tableRef({+ catalogName,+ schemaName,+ tableName,+ })} (${columnList}) ${source.sql}`,+ parameters: source.parameters,+ });+ },+});diff --git a/packages/pieces/community/databricks/src/lib/actions/run-query.ts b/packages/pieces/community/databricks/src/lib/actions/run-query.tsnew file mode 100644index 00000000000..aff0fc64e78--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/actions/run-query.ts@@ -0,0 +1,50 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { databricksAuth } from '../auth';+import { databricksApi } from '../common/api';+import { databricksProps } from '../common/props';+import { databricksUtils } from '../common/utils';+import { queryResultOutputSchema } from '../output-schemas';++export const runQueryAction = createAction({+ auth: databricksAuth,+ name: 'run_query',+ classification: 'WRITE',+ displayName: 'Run SQL Query',+ description:+ 'Runs any SQL statement on a SQL warehouse and returns the result rows.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Run an arbitrary Databricks SQL statement (SELECT, INSERT, MERGE, DDL, ...) on a SQL warehouse and return its rows. Prefer the table actions for simple reads and writes; use this for joins, aggregates or anything they cannot express. Pass user values as :named parameters, never inline. Retry safety depends on the statement.',+ idempotent: false,+ },+ props: {+ warehouseId: databricksProps.warehouseId({ required: true }),+ query: Property.LongText({+ displayName: 'SQL Query',+ description:+ 'The SQL statement to run. Use fully qualified table names and :name markers for values, e.g. SELECT * FROM main.sales.orders WHERE status = :status LIMIT 100',+ required: true,+ }),+ parameters: Property.Object({+ displayName: 'Parameters',+ description:+ 'Values for the :name markers in the query, e.g. status → shipped. Values are passed as strings; cast in SQL when needed, e.g. CAST(:amount AS DECIMAL(10,2)).',+ required: false,+ }),+ },+ outputSchema: queryResultOutputSchema,+ async run(context) {+ const { warehouseId, query, parameters } = context.propsValue;+ return await databricksApi.executeStatement({+ auth: context.auth,+ warehouseId,+ statement: query,+ parameters: Object.entries(parameters ?? {}).map(([name, value]) => ({+ name,+ value: databricksUtils.toParameterValue({ value }),+ })),+ });+ },+});diff --git a/packages/pieces/community/databricks/src/lib/actions/update-rows.ts b/packages/pieces/community/databricks/src/lib/actions/update-rows.tsnew file mode 100644index 00000000000..1ed6f55db66--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/actions/update-rows.ts@@ -0,0 +1,107 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { databricksAuth } from '../auth';+import { databricksApi } from '../common/api';+import { databricksProps } from '../common/props';+import { databricksUtils } from '../common/utils';+import { updateResultOutputSchema } from '../output-schemas';++export const updateRowsAction = createAction({+ auth: databricksAuth,+ name: 'update_rows',+ classification: 'WRITE',+ displayName: 'Update Rows',+ description:+ 'Updates the rows of a Unity Catalog table where a column matches a value.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Update every row of a Databricks Unity Catalog table whose match column equals the given value, setting only the columns you fill in. Use Upsert Row instead when the row may not exist yet. Setting the same values again is safe to retry.',+ idempotent: true,+ },+ props: {+ warehouseId: databricksProps.warehouseId({ required: true }),+ catalogName: databricksProps.catalogName({ required: true }),+ schemaName: databricksProps.schemaName({ required: true }),+ tableName: databricksProps.tableName({ required: true }),+ columnName: databricksProps.columnName({+ required: true,+ displayName: 'Match Column',+ description:+ 'Rows whose value in this column equals Match Value are updated.',+ }),+ matchValue: Property.ShortText({+ displayName: 'Match Value',+ description:+ 'The value to look for in the match column, e.g. 1042 or [email protected].',+ required: true,+ }),+ rowFields: databricksProps.rowFields({+ required: true,+ displayName: 'New Values',+ description:+ 'Fill in only the columns to change. Empty fields are left as they are.',+ }),+ },+ outputSchema: updateResultOutputSchema,+ async run(context) {+ const {+ warehouseId,+ catalogName,+ schemaName,+ tableName,+ columnName,+ matchValue,+ rowFields,+ } = context.propsValue;+ const table = await databricksApi.getTable({+ auth: context.auth,+ catalogName,+ schemaName,+ tableName,+ });+ const columns = table.columns ?? [];+ const values = databricksUtils.compactRow({ row: rowFields ?? {} });+ const changed = columns.filter(+ (column) => values[column.name] !== undefined+ );+ if (changed.length === 0) {+ throw new Error('Fill in at least one column to update.');+ }+ const assignments = changed.map((column, index) => {+ const name = databricksUtils.quoteIdentifier({ name: column.name });+ return `${name} = ${databricksUtils.convertToColumnType({+ column,+ expression: `:set${index}`,+ })}`;+ });+ const matchColumn = databricksUtils.findColumn({+ columns,+ name: columnName,+ });+ const statement = `UPDATE ${databricksUtils.tableRef({+ catalogName,+ schemaName,+ tableName,+ })} SET ${assignments.join(', ')} WHERE ${databricksUtils.quoteIdentifier({+ name: matchColumn.name,+ })} = ${databricksUtils.convertToColumnType({+ column: matchColumn,+ expression: ':match',+ })}`;+ return await databricksApi.executeWriteStatement({+ auth: context.auth,+ warehouseId,+ statement,+ parameters: [+ ...changed.map((column, index) => ({+ name: `set${index}`,+ value: databricksUtils.toParameterValue({+ value: values[column.name],+ }),+ })),+ { name: 'match', value: matchValue },+ ],+ });+ },+});diff --git a/packages/pieces/community/databricks/src/lib/actions/upload-file-to-volume.ts b/packages/pieces/community/databricks/src/lib/actions/upload-file-to-volume.tsnew file mode 100644index 00000000000..0fc5e45270d--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/actions/upload-file-to-volume.ts@@ -0,0 +1,252 @@+import { randomUUID } from 'node:crypto';++import { createAction, Property } from '@activepieces/pieces-framework';++import { databricksAuth } from '../auth';+import { databricksApi } from '../common/api';+import { databricksProps } from '../common/props';+import { databricksUtils } from '../common/utils';+import { loadFileOutputSchema } from '../output-schemas';++import type { DatabricksColumn, DatabricksFileColumn } from '../common/types';++const FILE_FORMATS: Record<+ string,+ {+ sqlFormat: string;+ readOptions: Record<string, string>;+ typeOptions: Record<string, string>;+ }+> = {+ CSV: {+ sqlFormat: 'CSV',+ readOptions: { header: 'true', multiLine: 'true', escape: '"' },+ typeOptions: { inferSchema: 'false' },+ },+ JSON_LINES: {+ sqlFormat: 'JSON',+ readOptions: { multiLine: 'false' },+ typeOptions: {},+ },+ JSON_ARRAY: {+ sqlFormat: 'JSON',+ readOptions: { multiLine: 'true' },+ typeOptions: {},+ },+};++const FILE_FORMAT_OPTIONS = [+ { label: 'CSV (first row is the header)', value: 'CSV' },+ { label: 'JSON (one object per line)', value: 'JSON_LINES' },+ {+ label: 'JSON (an array of objects, or one object over several lines)',+ value: 'JSON_ARRAY',+ },+];++export const uploadFileToVolumeAction = createAction({+ auth: databricksAuth,+ name: 'upload_file_to_volume',+ classification: 'WRITE',+ displayName: 'Upload File to Volume',+ description:+ 'Uploads a file to a Unity Catalog volume and, optionally, loads it into a table with COPY INTO.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Upload a file to a Databricks Unity Catalog volume and, when a table is chosen, load its CSV or JSON rows into that table with COPY INTO. Use this for bulk file loads; for a few rows built in the flow use Insert Multiple Rows. Each call stores the file under a new name and loads it again, so retries duplicate rows.',+ idempotent: false,+ },+ props: {+ catalogName: databricksProps.catalogName({ required: true }),+ schemaName: databricksProps.schemaName({ required: true }),+ volumeName: databricksProps.volumeName({ required: true }),+ file: Property.File({+ displayName: 'File',+ description:+ 'The file to upload, e.g. a CSV or JSON file from an FTP, email or HTTP step.',+ required: true,+ }),+ folder: Property.ShortText({+ displayName: 'Folder',+ description:+ 'Optional folder inside the volume, e.g. imports/orders. It is created if it does not exist.',+ required: false,+ }),+ tableName: databricksProps.tableName({+ required: false,+ displayName: 'Load into Table',+ description:+ 'Optional. A table in the same catalog and schema to load the file into with COPY INTO. Leave empty to only upload the file.',+ }),+ warehouseId: databricksProps.warehouseId({+ required: false,+ description:+ 'The SQL warehouse that runs COPY INTO. Required when Load into Table is set.',+ }),+ fileFormat: Property.StaticDropdown({+ displayName: 'File Format',+ description: 'How the file is read when it is loaded into the table.',+ required: false,+ defaultValue: 'CSV',+ options: { options: FILE_FORMAT_OPTIONS },+ }),+ shouldMergeSchema: Property.Checkbox({+ displayName: 'Add New Columns',+ description:+ 'When the file has columns the table does not, add them to the table instead of failing.',+ required: false,+ defaultValue: false,+ }),+ },+ outputSchema: loadFileOutputSchema,+ async run(context) {+ const {+ catalogName,+ schemaName,+ volumeName,+ file,+ folder,+ tableName,+ warehouseId,+ fileFormat,+ shouldMergeSchema,+ } = context.propsValue;+ if (tableName && !warehouseId) {+ throw new Error(+ 'Select a SQL warehouse to load the file into the table.'+ );+ }+ const format = FILE_FORMATS[fileFormat ?? 'CSV'];+ if (!format) {+ throw new Error(`Unsupported file format: ${fileFormat}`);+ }+ const fileName = `${Date.now()}-${randomUUID()}-${file.filename.replace(+ /[^A-Za-z0-9._-]/g,+ '_'+ )}`;+ const folderSegments = (folder ?? '')+ .split('/')+ .filter((segment) => segment.trim() !== '');+ const directory = [+ '',+ 'Volumes',+ catalogName,+ schemaName,+ volumeName,+ ...folderSegments,+ ].join('/');+ const filePath = `${directory}/${fileName}`;+ await databricksApi.uploadFile({+ auth: context.auth,+ path: filePath,+ data: file.data,+ });+ if (!tableName || !warehouseId) {+ return { filePath };+ }+ const [table, fileColumns] = await Promise.all([+ databricksApi.getTable({+ auth: context.auth,+ catalogName,+ schemaName,+ tableName,+ }),+ databricksApi.getFileColumns({+ auth: context.auth,+ warehouseId,+ path: filePath,+ format: format.sqlFormat.toLowerCase(),+ options: format.readOptions,+ }),+ ]);+ if (fileColumns.length === 0) {+ throw new Error('The file has no columns to load.');+ }+ const selectList = fileColumns+ .map((source) => {+ const target = (table.columns ?? []).find(+ (column) => column.name.toLowerCase() === source.name.toLowerCase()+ );+ return target+ ? `${castFileColumn({+ source,+ target,+ })} AS ${databricksUtils.quoteIdentifier({ name: target.name })}`+ : databricksUtils.quoteIdentifier({ name: source.name });+ })+ .join(', ');+ const formatOptions = {+ ...format.readOptions,+ ...format.typeOptions,+ ...(shouldMergeSchema ? { mergeSchema: 'true' } : {}),+ };+ const statement = [+ `COPY INTO ${databricksUtils.tableRef({+ catalogName,+ schemaName,+ tableName,+ })}`,+ `FROM (SELECT ${selectList} FROM ${databricksUtils.stringLiteral({+ value: directory,+ })})`,+ `FILEFORMAT = ${format.sqlFormat}`,+ `FILES = (${databricksUtils.stringLiteral({ value: fileName })})`,+ `FORMAT_OPTIONS (${toOptionList({ options: formatOptions })})`,+ shouldMergeSchema ? `COPY_OPTIONS ('mergeSchema' = 'true')` : '',+ ]+ .filter((line) => line !== '')+ .join(' ');+ const result = await databricksApi.executeWriteStatement({+ auth: context.auth,+ warehouseId,+ statement,+ });+ return { filePath, ...result };+ },+});++function castFileColumn({+ source,+ target,+}: {+ source: DatabricksFileColumn;+ target: DatabricksColumn;+}): string {+ const name = databricksUtils.quoteIdentifier({ name: source.name });+ const sourceType = (source.type_name ?? 'STRING').toUpperCase();+ const targetType = (target.type_name ?? 'STRING').toUpperCase();+ if (COMPLEX_TYPES.includes(sourceType)) {+ const json = `to_json(${name})`;+ return targetType === 'STRING'+ ? json+ : databricksUtils.convertToColumnType({+ column: target,+ expression: json,+ });+ }+ if (targetType === 'STRING') {+ return `CAST(${name} AS STRING)`;+ }+ return databricksUtils.convertToColumnType({+ column: target,+ expression: name,+ });+}++function toOptionList({+ options,+}: {+ options: Record<string, string>;+}): string {+ return Object.entries(options)+ .map(+ ([key, value]) =>+ `${databricksUtils.stringLiteral({+ value: key,+ })} = ${databricksUtils.stringLiteral({ value })}`+ )+ .join(', ');+}++const COMPLEX_TYPES = ['ARRAY', 'MAP', 'STRUCT'];diff --git a/packages/pieces/community/databricks/src/lib/actions/upsert-row.ts b/packages/pieces/community/databricks/src/lib/actions/upsert-row.tsnew file mode 100644index 00000000000..5f06658f17e--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/actions/upsert-row.ts@@ -0,0 +1,94 @@+import { createAction } from '@activepieces/pieces-framework';++import { databricksAuth } from '../auth';+import { databricksApi } from '../common/api';+import { databricksProps } from '../common/props';+import { databricksUtils } from '../common/utils';+import { upsertResultOutputSchema } from '../output-schemas';++export const upsertRowAction = createAction({+ auth: databricksAuth,+ name: 'upsert_row',+ classification: 'WRITE',+ displayName: 'Upsert Row',+ description:+ 'Updates the row with a matching key, or inserts it if no row matches (MERGE).',+ audience: 'both',+ aiMetadata: {+ description:+ 'Insert or update one row in a Databricks Unity Catalog table using MERGE, matched on a key column. Use this when you do not know whether the row exists; the key column value is required. Keyed on a stable value, so safe to retry.',+ idempotent: true,+ },+ props: {+ warehouseId: databricksProps.warehouseId({ required: true }),+ catalogName: databricksProps.catalogName({ required: true }),+ schemaName: databricksProps.schemaName({ required: true }),+ tableName: databricksProps.tableName({ required: true }),+ columnName: databricksProps.columnName({+ required: true,+ displayName: 'Key Column',+ description:+ 'The column that identifies a row, e.g. id or email. A row with the same value is updated; otherwise a new row is inserted.',+ }),+ rowFields: databricksProps.rowFields({+ required: true,+ description:+ 'One field per table column. The key column must be filled in. Empty fields are not changed on update and inserted as NULL.',+ }),+ },+ outputSchema: upsertResultOutputSchema,+ async run(context) {+ const {+ warehouseId,+ catalogName,+ schemaName,+ tableName,+ columnName,+ rowFields,+ } = context.propsValue;+ const table = await databricksApi.getTable({+ auth: context.auth,+ catalogName,+ schemaName,+ tableName,+ });+ const row = databricksUtils.compactRow({ row: rowFields ?? {} });+ if (row[columnName] === undefined) {+ throw new Error(`Fill in the key column "${columnName}".`);+ }+ const source = databricksUtils.buildRowSource({+ columns: table.columns ?? [],+ rows: [row],+ });+ const quoted = source.columnNames.map((name) =>+ databricksUtils.quoteIdentifier({ name })+ );+ const key = databricksUtils.quoteIdentifier({ name: columnName });+ const updates = quoted+ .filter((name) => name !== key)+ .map((name) => `target.${name} = source.${name}`);+ const statement = [+ `MERGE INTO ${databricksUtils.tableRef({+ catalogName,+ schemaName,+ tableName,+ })} AS target`,+ `USING (${source.sql}) AS source`,+ `ON target.${key} = source.${key}`,+ updates.length > 0+ ? `WHEN MATCHED THEN UPDATE SET ${updates.join(', ')}`+ : '',+ `WHEN NOT MATCHED THEN INSERT (${quoted.join(', ')}) VALUES (${quoted+ .map((name) => `source.${name}`)+ .join(', ')})`,+ ]+ .filter((line) => line !== '')+ .join(' ');+ return await databricksApi.executeWriteStatement({+ auth: context.auth,+ warehouseId,+ statement,+ parameters: source.parameters,+ });+ },+});diff --git a/packages/pieces/community/databricks/src/lib/auth.ts b/packages/pieces/community/databricks/src/lib/auth.tsnew file mode 100644index 00000000000..f26965da615--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/auth.ts@@ -0,0 +1,64 @@+import {+ AppConnectionType,+ PieceAuth,+ Property,+} from '@activepieces/pieces-framework';++import { databricksApi } from './common/api';++export const databricksAuth = PieceAuth.CustomAuth({+ displayName: 'Service Principal',+ description: `Connect with a Databricks service principal (OAuth machine-to-machine). Activepieces exchanges the client ID and secret for short-lived access tokens automatically.++1. In your Databricks workspace, open **Settings → Identity and access → Service principals** and add (or pick) a service principal.+2. On the service principal's **Secrets** tab, click **Generate secret** and copy the **Client ID** and **Secret**.+3. Grant the service principal **Can use** on the SQL warehouse, and the Unity Catalog privileges it needs (for example \`USE CATALOG\`, \`USE SCHEMA\`, \`SELECT\`, \`MODIFY\`, \`READ VOLUME\`, \`WRITE VOLUME\`). For Genie, give it **Can run** on the Genie space.+4. Copy your workspace URL from the browser address bar, e.g. \`https://dbc-a1b2c3d4-e5f6.cloud.databricks.com\`.`,+ required: true,+ props: {+ workspaceUrl: Property.ShortText({+ displayName: 'Workspace URL',+ description:+ 'Your Databricks workspace URL, e.g. https://dbc-a1b2c3d4-e5f6.cloud.databricks.com or https://adb-1234567890123456.7.azuredatabricks.net',+ required: true,+ }),+ clientId: Property.ShortText({+ displayName: 'Client ID',+ description:+ "The service principal's client ID (also called application ID), e.g. 6b1d5c2e-0a4f-4c3b-9f1e-2d7a8b9c0d1e.",+ required: true,+ }),+ clientSecret: PieceAuth.SecretText({+ displayName: 'Client Secret',+ description:+ "The OAuth secret generated on the service principal's Secrets tab.",+ required: true,+ }),+ },+ validate: async ({ auth }) => {+ try {+ const token = await databricksApi.getAccessToken({ credentials: auth });+ await databricksApi.getCurrentUser({+ auth: {+ type: AppConnectionType.CUSTOM_AUTH,+ access_token: token.access_token,+ props: auth,+ },+ });+ return { valid: true };+ } catch {+ return {+ valid: false,+ error:+ 'Could not sign in to Databricks. Check the workspace URL, client ID and client secret.',+ };+ }+ },+ refresh: {+ generate: async ({ auth }) => {+ const token = await databricksApi.getAccessToken({ credentials: auth });+ return { access_token: token.access_token, expires_in: token.expires_in };+ },+ defaultExpiresIn: 3600,+ },+});diff --git a/packages/pieces/community/databricks/src/lib/common/api.ts b/packages/pieces/community/databricks/src/lib/common/api.tsnew file mode 100644index 00000000000..22301727fe2--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/common/api.ts@@ -0,0 +1,533 @@+import { HttpMethod } from '@activepieces/pieces-common';++import { databricksClient } from './client';+import { databricksUtils } from './utils';++import type {+ DatabricksAuthValue,+ DatabricksCredentials,+ DatabricksFileColumn,+ DatabricksGenieAnswer,+ DatabricksGenieMessage,+ DatabricksGenieSpace,+ DatabricksNamed,+ DatabricksQueryResult,+ DatabricksResultChunk,+ DatabricksStatement,+ DatabricksStatementParameter,+ DatabricksTable,+ DatabricksToken,+ DatabricksWarehouse,+} from './types';++async function getAccessToken({+ credentials,+}: {+ credentials: DatabricksCredentials;+}): Promise<DatabricksToken> {+ return await databricksClient.fetchToken({ credentials });+}++async function getCurrentUser({+ auth,+}: {+ auth: DatabricksAuthValue;+}): Promise<{ userName?: string; displayName?: string }> {+ return await databricksClient.request<{+ userName?: string;+ displayName?: string;+ }>({+ auth,+ method: HttpMethod.GET,+ path: '/api/2.0/preview/scim/v2/Me',+ });+}++async function listWarehouses({+ auth,+}: {+ auth: DatabricksAuthValue;+}): Promise<DatabricksWarehouse[]> {+ const response = await databricksClient.request<{+ warehouses?: DatabricksWarehouse[];+ }>({+ auth,+ method: HttpMethod.GET,+ path: '/api/2.0/sql/warehouses',+ });+ return response.warehouses ?? [];+}++async function listCatalogs({+ auth,+}: {+ auth: DatabricksAuthValue;+}): Promise<DatabricksNamed[]> {+ return await databricksClient.paginate<'catalogs', DatabricksNamed>({+ auth,+ path: '/api/2.1/unity-catalog/catalogs',+ itemsKey: 'catalogs',+ });+}++async function listSchemas({+ auth,+ catalogName,+}: {+ auth: DatabricksAuthValue;+ catalogName: string;+}): Promise<DatabricksNamed[]> {+ return await databricksClient.paginate<'schemas', DatabricksNamed>({+ auth,+ path: '/api/2.1/unity-catalog/schemas',+ query: { catalog_name: catalogName },+ itemsKey: 'schemas',+ });+}++async function listTables({+ auth,+ catalogName,+ schemaName,+}: {+ auth: DatabricksAuthValue;+ catalogName: string;+ schemaName: string;+}): Promise<DatabricksNamed[]> {+ return await databricksClient.paginate<'tables', DatabricksNamed>({+ auth,+ path: '/api/2.1/unity-catalog/tables',+ query: {+ catalog_name: catalogName,+ schema_name: schemaName,+ omit_columns: 'true',+ },+ itemsKey: 'tables',+ });+}++async function listVolumes({+ auth,+ catalogName,+ schemaName,+}: {+ auth: DatabricksAuthValue;+ catalogName: string;+ schemaName: string;+}): Promise<DatabricksNamed[]> {+ return await databricksClient.paginate<'volumes', DatabricksNamed>({+ auth,+ path: '/api/2.1/unity-catalog/volumes',+ query: { catalog_name: catalogName, schema_name: schemaName },+ itemsKey: 'volumes',+ });+}++async function getTable({+ auth,+ catalogName,+ schemaName,+ tableName,+}: {+ auth: DatabricksAuthValue;+ catalogName: string;+ schemaName: string;+ tableName: string;+}): Promise<DatabricksTable> {+ const fullName = [catalogName, schemaName, tableName].join('.');+ return await databricksClient.request<DatabricksTable>({+ auth,+ method: HttpMethod.GET,+ path: `/api/2.1/unity-catalog/tables/${encodeURIComponent(fullName)}`,+ });+}++async function executeStatement({+ auth,+ warehouseId,+ statement,+ parameters,+}: {+ auth: DatabricksAuthValue;+ warehouseId: string;+ statement: string;+ parameters?: DatabricksStatementParameter[];+}): Promise<DatabricksQueryResult> {+ const finished = await runStatement({+ auth,+ warehouseId,+ statement,+ parameters,+ });+ const chunks = await fetchRemainingChunks({+ auth,+ statementId: finished.statement_id,+ first: finished.result,+ });+ return toQueryResult({ statement: finished, dataArray: chunks });+}++async function executeWriteStatement({+ auth,+ warehouseId,+ statement,+ parameters,+}: {+ auth: DatabricksAuthValue;+ warehouseId: string;+ statement: string;+ parameters?: DatabricksStatementParameter[];+}): Promise<Record<string, unknown>> {+ const result = await executeStatement({+ auth,+ warehouseId,+ statement,+ parameters,+ });+ return { ...result.rows[0], statementId: result.statementId };+}++async function getFileColumns({+ auth,+ warehouseId,+ path,+ format,+ options,+}: {+ auth: DatabricksAuthValue;+ warehouseId: string;+ path: string;+ format: string;+ options: Record<string, string>;+}): Promise<DatabricksFileColumn[]> {+ const optionList = Object.entries({ format, ...options })+ .map(+ ([key, value]) =>+ `${key} => ${databricksUtils.stringLiteral({ value })}`+ )+ .join(', ');+ const finished = await runStatement({+ auth,+ warehouseId,+ statement: `SELECT * FROM read_files(${databricksUtils.stringLiteral({+ value: path,+ })}, ${optionList}) LIMIT 0`,+ });+ return (finished.manifest?.schema?.columns ?? []).filter(+ (column) => column.name !== RESCUED_DATA_COLUMN+ );+}++async function uploadFile({+ auth,+ path,+ data,+}: {+ auth: DatabricksAuthValue;+ path: string;+ data: Buffer;+}): Promise<void> {+ const encodedPath = path+ .split('/')+ .map((segment) => encodeURIComponent(segment))+ .join('/');+ await databricksClient.request<unknown>({+ auth,+ method: HttpMethod.PUT,+ path: `/api/2.0/fs/files${encodedPath}`,+ query: { overwrite: 'false' },+ headers: { 'Content-Type': 'application/octet-stream' },+ body: data,+ });+}++async function listGenieSpaces({+ auth,+}: {+ auth: DatabricksAuthValue;+}): Promise<DatabricksGenieSpace[]> {+ return await databricksClient.paginate<'spaces', DatabricksGenieSpace>({+ auth,+ path: '/api/2.0/genie/spaces',+ itemsKey: 'spaces',+ });+}++async function askGenie({+ auth,+ spaceId,+ question,+ conversationId,+}: {+ auth: DatabricksAuthValue;+ spaceId: string;+ question: string;+ conversationId?: string;+}): Promise<DatabricksGenieAnswer> {+ const posted = await databricksClient.request<DatabricksGenieMessage>({+ auth,+ method: HttpMethod.POST,+ path: conversationId+ ? `/api/2.0/genie/spaces/${spaceId}/conversations/${conversationId}/messages`+ : `/api/2.0/genie/spaces/${spaceId}/start-conversation`,+ body: { content: question },+ });+ const ids = {+ conversationId: posted.conversation_id,+ messageId: posted.message_id ?? posted.id ?? '',+ };+ const message = await waitForGenieMessage({ auth, spaceId, ...ids });+ const answer =+ message.attachments+ ?.map((a) => a.text?.content)+ .filter((text) => !!text)+ .join('\n\n') ?? '';+ const queryAttachment = message.attachments?.find((a) => a.query);+ const result = queryAttachment?.attachment_id+ ? await getGenieQueryResult({+ auth,+ spaceId,+ ...ids,+ attachmentId: queryAttachment.attachment_id,+ })+ : undefined;+ return {+ conversationId: ids.conversationId,+ messageId: ids.messageId,+ status: message.status,+ answer,+ sql: queryAttachment?.query?.query ?? null,+ queryDescription: queryAttachment?.query?.description ?? null,+ columns: result?.columns ?? [],+ rows: result?.rows ?? [],+ rowCount: result?.rowCount ?? 0,+ truncated: result?.truncated ?? false,+ };+}++async function runStatement({+ auth,+ warehouseId,+ statement,+ parameters,+}: {+ auth: DatabricksAuthValue;+ warehouseId: string;+ statement: string;+ parameters?: DatabricksStatementParameter[];+}): Promise<DatabricksStatement> {+ const submitted = await databricksClient.request<DatabricksStatement>({+ auth,+ method: HttpMethod.POST,+ path: '/api/2.0/sql/statements',+ body: {+ warehouse_id: warehouseId,+ statement,+ parameters,+ wait_timeout: '50s',+ on_wait_timeout: 'CONTINUE',+ disposition: 'INLINE',+ format: 'JSON_ARRAY',+ },+ });+ return await waitForStatement({ auth, statement: submitted });+}++async function waitForStatement({+ auth,+ statement,+}: {+ auth: DatabricksAuthValue;+ statement: DatabricksStatement;+}): Promise<DatabricksStatement> {+ const deadline = Date.now() + MAX_WAIT_MS;+ let current = statement;+ while (PENDING_STATEMENT_STATES.includes(current.status.state)) {+ if (Date.now() > deadline) {+ await databricksClient.request<unknown>({+ auth,+ method: HttpMethod.POST,+ path: `/api/2.0/sql/statements/${current.statement_id}/cancel`,+ });+ throw new Error(+ 'The SQL statement did not finish within 8 minutes and was canceled.'+ );+ }+ await sleep({ ms: POLL_INTERVAL_MS });+ current = await databricksClient.request<DatabricksStatement>({+ auth,+ method: HttpMethod.GET,+ path: `/api/2.0/sql/statements/${current.statement_id}`,+ });+ }+ if (current.status.state !== 'SUCCEEDED') {+ throw new Error(+ `SQL statement ${current.status.state.toLowerCase()}: ${+ current.status.error?.message ?? 'no error message returned'+ }`+ );+ }+ return current;+}++async function fetchRemainingChunks({+ auth,+ statementId,+ first,+}: {+ auth: DatabricksAuthValue;+ statementId: string;+ first?: DatabricksResultChunk;+}): Promise<(string | null)[][]> {+ const chunks = [first?.data_array ?? []];+ let nextChunk = first?.next_chunk_index;+ while (nextChunk !== undefined) {+ const chunk = await databricksClient.request<DatabricksResultChunk>({+ auth,+ method: HttpMethod.GET,+ path: `/api/2.0/sql/statements/${statementId}/result/chunks/${nextChunk}`,+ });+ chunks.push(chunk.data_array ?? []);+ nextChunk = chunk.next_chunk_index;+ }+ return chunks.flat();+}++async function waitForGenieMessage({+ auth,+ spaceId,+ conversationId,+ messageId,+}: GenieMessageIds & {+ auth: DatabricksAuthValue;+}): Promise<DatabricksGenieMessage> {+ const deadline = Date.now() + MAX_WAIT_MS;+ for (;;) {+ const message = await databricksClient.request<DatabricksGenieMessage>({+ auth,+ method: HttpMethod.GET,+ path: `/api/2.0/genie/spaces/${spaceId}/conversations/${conversationId}/messages/${messageId}`,+ });+ if (message.status === 'COMPLETED') {+ return message;+ }+ if (FAILED_GENIE_STATES.includes(message.status)) {+ throw new Error(+ `Genie could not answer (${message.status}): ${+ message.error?.error ?? 'no error message returned'+ }`+ );+ }+ if (Date.now() > deadline) {+ throw new Error('Genie did not answer within 8 minutes.');+ }+ await sleep({ ms: POLL_INTERVAL_MS });+ }+}++async function getGenieQueryResult({+ auth,+ spaceId,+ conversationId,+ messageId,+ attachmentId,+}: GenieMessageIds & {+ auth: DatabricksAuthValue;+ attachmentId: string;+}): Promise<DatabricksQueryResult> {+ const response = await databricksClient.request<{+ statement_response: DatabricksStatement;+ }>({+ auth,+ method: HttpMethod.GET,+ path: `/api/2.0/genie/spaces/${spaceId}/conversations/${conversationId}/messages/${messageId}/attachments/${attachmentId}/query-result`,+ });+ const dataArray = await fetchRemainingChunks({+ auth,+ statementId: response.statement_response.statement_id,+ first: response.statement_response.result,+ });+ return toQueryResult({ statement: response.statement_response, dataArray });+}++function toQueryResult({+ statement,+ dataArray,+}: {+ statement: DatabricksStatement;+ dataArray: (string | null)[][];+}): DatabricksQueryResult {+ const columns = statement.manifest?.schema?.columns ?? [];+ const rows = dataArray.map((values) =>+ Object.fromEntries(+ columns.map((column, index) => [+ column.name,+ parseValue({ value: values[index], typeName: column.type_name }),+ ])+ )+ );+ return {+ statementId: statement.statement_id,+ columns: columns.map((column) => column.name),+ rows,+ rowCount: rows.length,+ truncated: statement.manifest?.truncated ?? false,+ };+}++function parseValue({+ value,+ typeName,+}: {+ value: string | null | undefined;+ typeName?: string;+}): unknown {+ if (value === null || value === undefined) {+ return null;+ }+ if (typeName === 'BOOLEAN') {+ return value === 'true';+ }+ if (typeName && NUMERIC_TYPES.includes(typeName)) {+ const parsed = Number(value);+ return Number.isSafeInteger(parsed) ||+ (typeName !== 'LONG' && Number.isFinite(parsed))+ ? parsed+ : value;+ }+ return value;+}++function sleep({ ms }: { ms: number }): Promise<void> {+ return new Promise((resolve) => setTimeout(resolve, ms));+}++export const databricksApi = {+ getAccessToken,+ getCurrentUser,+ listWarehouses,+ listCatalogs,+ listSchemas,+ listTables,+ listVolumes,+ getTable,+ executeStatement,+ executeWriteStatement,+ getFileColumns,+ uploadFile,+ listGenieSpaces,+ askGenie,+};++const POLL_INTERVAL_MS = 2000;+const MAX_WAIT_MS = 8 * 60 * 1000;+const PENDING_STATEMENT_STATES = ['PENDING', 'RUNNING'];+const FAILED_GENIE_STATES = ['FAILED', 'CANCELLED', 'QUERY_RESULT_EXPIRED'];+const RESCUED_DATA_COLUMN = '_rescued_data';+const NUMERIC_TYPES = ['BYTE', 'SHORT', 'INT', 'LONG', 'FLOAT', 'DOUBLE'];++type GenieMessageIds = {+ spaceId: string;+ conversationId: string;+ messageId: string;+};diff --git a/packages/pieces/community/databricks/src/lib/common/client.ts b/packages/pieces/community/databricks/src/lib/common/client.tsnew file mode 100644index 00000000000..c63df9d8bed--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/common/client.ts@@ -0,0 +1,138 @@+import {+ AuthenticationType,+ HttpMethod,+ httpClient,+ QueryParams,+} from '@activepieces/pieces-common';++import type {+ DatabricksAuthValue,+ DatabricksCredentials,+ DatabricksPage,+ DatabricksToken,+} from './types';++function baseUrl({ auth }: { auth: DatabricksAuthValue }): string {+ return normalizeWorkspaceUrl({ workspaceUrl: auth.props.workspaceUrl });+}++function normalizeWorkspaceUrl({+ workspaceUrl,+}: {+ workspaceUrl: string;+}): string {+ const host = workspaceUrl+ .trim()+ .replace(/^[a-z]+:\/\//i, '')+ .replace(/\/+$/, '');+ return `https://${host}`;+}++function isWorkspaceUrl({+ auth,+ url,+}: {+ auth: DatabricksAuthValue;+ url: string;+}): boolean {+ if (!/^https?:\/\//i.test(url)) {+ return true;+ }+ return (+ URL.canParse(url) &&+ new URL(url).origin === new URL(baseUrl({ auth })).origin+ );+}++async function fetchToken({+ credentials,+}: {+ credentials: DatabricksCredentials;+}): Promise<DatabricksToken> {+ const response = await httpClient.sendRequest<DatabricksToken>({+ method: HttpMethod.POST,+ url: `${normalizeWorkspaceUrl({+ workspaceUrl: credentials.workspaceUrl,+ })}/oidc/v1/token`,+ authentication: {+ type: AuthenticationType.BASIC,+ username: credentials.clientId,+ password: credentials.clientSecret,+ },+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },+ body: 'grant_type=client_credentials&scope=all-apis',+ });+ return response.body;+}++async function request<T>({+ auth,+ method,+ path,+ query,+ body,+ headers,+}: RequestParams & { auth: DatabricksAuthValue }): Promise<T> {+ const token =+ auth.access_token ??+ (await fetchToken({ credentials: auth.props })).access_token;+ const response = await httpClient.sendRequest<T>({+ method,+ url: `${baseUrl({ auth })}${path}`,+ authentication: { type: AuthenticationType.BEARER_TOKEN, token },+ queryParams: query,+ headers,+ body,+ });+ return response.body;+}++async function paginate<K extends string, T>({+ auth,+ path,+ query,+ itemsKey,+ maxItems = MAX_ITEMS,+}: PaginateParams<K> & { auth: DatabricksAuthValue }): Promise<T[]> {+ const pages: T[][] = [];+ let itemCount = 0;+ let pageToken: string | undefined;+ do {+ const page = await request<DatabricksPage<K, T>>({+ auth,+ method: HttpMethod.GET,+ path,+ query: { ...query, ...(pageToken ? { page_token: pageToken } : {}) },+ });+ const pageItems = page[itemsKey] ?? [];+ pages.push(pageItems);+ itemCount += pageItems.length;+ pageToken = page.next_page_token;+ } while (pageToken && itemCount < maxItems);+ return pages.flat().slice(0, maxItems);+}++export const databricksClient = {+ baseUrl,+ isWorkspaceUrl,+ fetchToken,+ request,+ paginate,+};++const MAX_ITEMS = 1000;++type RequestParams = {+ method: HttpMethod;+ path: string;+ query?: QueryParams;+ body?: unknown;+ headers?: Record<string, string>;+};++type PaginateParams<K extends string> = {+ path: string;+ query?: QueryParams;+ itemsKey: K;+ maxItems?: number;+};diff --git a/packages/pieces/community/databricks/src/lib/common/props.ts b/packages/pieces/community/databricks/src/lib/common/props.tsnew file mode 100644index 00000000000..11cb285a68c--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/common/props.ts@@ -0,0 +1,375 @@+import {+ DropdownState,+ DynamicPropsValue,+ Property,+} from '@activepieces/pieces-framework';++import { databricksAuth } from '../auth';+import { databricksApi } from './api';+import type { DatabricksColumn } from './types';++function warehouseId<R extends boolean>({+ required,+ displayName = 'SQL Warehouse',+ description = 'The SQL warehouse that runs the statement. The service principal needs "Can use" permission on it.',+}: PropParams<R>) {+ return Property.Dropdown({+ auth: databricksAuth,+ displayName,+ description,+ required,+ refreshers: [],+ options: async ({ auth }) => {+ if (!auth) {+ return disabledOptions({+ placeholder: 'Please connect your account first.',+ });+ }+ const warehouses = await databricksApi.listWarehouses({ auth });+ return {+ disabled: false,+ options: warehouses.map((warehouse) => ({+ label: warehouse.state+ ? `${warehouse.name} (${warehouse.state.toLowerCase()})`+ : warehouse.name,+ value: warehouse.id,+ })),+ placeholder:+ warehouses.length === 0 ? 'No SQL warehouses found.' : undefined,+ };+ },+ });+}++function catalogName<R extends boolean>({+ required,+ displayName = 'Catalog',+ description = 'The Unity Catalog catalog.',+}: PropParams<R>) {+ return Property.Dropdown({+ auth: databricksAuth,+ displayName,+ description,+ required,+ refreshers: [],+ options: async ({ auth }) => {+ if (!auth) {+ return disabledOptions({+ placeholder: 'Please connect your account first.',+ });+ }+ const catalogs = await databricksApi.listCatalogs({ auth });+ return {+ disabled: false,+ options: catalogs.map((catalog) => ({+ label: catalog.name,+ value: catalog.name,+ })),+ };+ },+ });+}++function schemaName<R extends boolean>({+ required,+ displayName = 'Schema',+ description = 'The schema inside the selected catalog.',+}: PropParams<R>) {+ return Property.Dropdown({+ auth: databricksAuth,+ displayName,+ description,+ required,+ refreshers: ['catalogName'],+ options: async ({ auth, catalogName }) => {+ if (!auth) {+ return disabledOptions({+ placeholder: 'Please connect your account first.',+ });+ }+ if (!catalogName) {+ return disabledOptions({+ placeholder: 'Please select a catalog first.',+ });+ }+ const schemas = await databricksApi.listSchemas({+ auth,+ catalogName: String(catalogName),+ });+ return {+ disabled: false,+ options: schemas.map((schema) => ({+ label: schema.name,+ value: schema.name,+ })),+ };+ },+ });+}++function tableName<R extends boolean>({+ required,+ displayName = 'Table',+ description = 'The table inside the selected schema.',+}: PropParams<R>) {+ return Property.Dropdown({+ auth: databricksAuth,+ displayName,+ description,+ required,+ refreshers: ['catalogName', 'schemaName'],+ options: async ({ auth, catalogName, schemaName }) => {+ if (!auth) {+ return disabledOptions({+ placeholder: 'Please connect your account first.',+ });+ }+ if (!catalogName || !schemaName) {+ return disabledOptions({+ placeholder: 'Please select a catalog and schema first.',+ });+ }+ const tables = await databricksApi.listTables({+ auth,+ catalogName: String(catalogName),+ schemaName: String(schemaName),+ });+ return {+ disabled: false,+ options: tables.map((table) => ({+ label: table.name,+ value: table.name,+ })),+ };+ },+ });+}++function volumeName<R extends boolean>({+ required,+ displayName = 'Volume',+ description = 'The Unity Catalog volume the file is uploaded to, inside the selected schema.',+}: PropParams<R>) {+ return Property.Dropdown({+ auth: databricksAuth,+ displayName,+ description,+ required,+ refreshers: ['catalogName', 'schemaName'],+ options: async ({ auth, catalogName, schemaName }) => {+ if (!auth) {+ return disabledOptions({+ placeholder: 'Please connect your account first.',+ });+ }+ if (!catalogName || !schemaName) {+ return disabledOptions({+ placeholder: 'Please select a catalog and schema first.',+ });+ }+ const volumes = await databricksApi.listVolumes({+ auth,+ catalogName: String(catalogName),+ schemaName: String(schemaName),+ });+ return {+ disabled: false,+ options: volumes.map((volume) => ({+ label: volume.name,+ value: volume.name,+ })),+ placeholder:+ volumes.length === 0 ? 'No volumes found in this schema.' : undefined,+ };+ },+ });+}++function columnName<R extends boolean>({+ required,+ displayName = 'Column',+ description = 'A column of the selected table.',+}: PropParams<R>) {+ return Property.Dropdown({+ auth: databricksAuth,+ displayName,+ description,+ required,+ refreshers: ['catalogName', 'schemaName', 'tableName'],+ options: async ({ auth, catalogName, schemaName, tableName }) => {+ if (!auth) {+ return disabledOptions({+ placeholder: 'Please connect your account first.',+ });+ }+ if (!catalogName || !schemaName || !tableName) {+ return disabledOptions({ placeholder: 'Please select a table first.' });+ }+ const table = await databricksApi.getTable({+ auth,+ catalogName: String(catalogName),+ schemaName: String(schemaName),+ tableName: String(tableName),+ });+ return {+ disabled: false,+ options: (table.columns ?? []).map((column) => ({+ label: `${column.name} (${+ column.type_text ?? column.type_name ?? 'unknown'+ })`,+ value: column.name,+ })),+ };+ },+ });+}++function rowFields<R extends boolean>({+ required,+ displayName = 'Values',+ description = 'One field per table column. Leave a field empty to skip that column.',+}: PropParams<R>) {+ return Property.DynamicProperties({+ auth: databricksAuth,+ displayName,+ description,+ required,+ refreshers: ['catalogName', 'schemaName', 'tableName'],+ props: async ({+ auth,+ catalogName,+ schemaName,+ tableName,+ }): Promise<DynamicPropsValue> => {+ if (!auth || !catalogName || !schemaName || !tableName) {+ return {};+ }+ const table = await databricksApi.getTable({+ auth,+ catalogName: String(catalogName),+ schemaName: String(schemaName),+ tableName: String(tableName),+ });+ return columnInputs({ columns: table.columns ?? [] });+ },+ });+}++function rowList<R extends boolean>({+ required,+ displayName = 'Rows',+ description = 'One item per row. Leave a field empty to insert NULL.',+}: PropParams<R>) {+ return Property.DynamicProperties({+ auth: databricksAuth,+ displayName,+ required,+ refreshers: ['catalogName', 'schemaName', 'tableName'],+ props: async ({+ auth,+ catalogName,+ schemaName,+ tableName,+ }): Promise<DynamicPropsValue> => {+ if (!auth || !catalogName || !schemaName || !tableName) {+ return {};+ }+ const table = await databricksApi.getTable({+ auth,+ catalogName: String(catalogName),+ schemaName: String(schemaName),+ tableName: String(tableName),+ });+ return {+ rows: Property.Array({+ displayName,+ description,+ required: true,+ properties: columnInputs({ columns: table.columns ?? [] }),+ }),+ };+ },+ });+}++function columnInputs({+ columns,+}: {+ columns: DatabricksColumn[];+}): DynamicPropsValue {+ return Object.fromEntries(+ columns.map((column) => [+ column.name,+ Property.ShortText({+ displayName: column.name,+ description: [+ `Type: ${column.type_text ?? column.type_name ?? 'unknown'}.`,+ column.type_name &&+ ['ARRAY', 'MAP', 'STRUCT', 'VARIANT'].includes(column.type_name)+ ? 'Enter JSON.'+ : '',+ column.comment ?? '',+ ]+ .filter((part) => part !== '')+ .join(' '),+ required: false,+ }),+ ])+ );+}++function genieSpaceId<R extends boolean>({+ required,+ displayName = 'Genie Space',+ description = 'The Genie space to ask. The service principal needs "Can run" permission on it.',+}: PropParams<R>) {+ return Property.Dropdown({+ auth: databricksAuth,+ displayName,+ description,+ required,+ refreshers: [],+ options: async ({ auth }) => {+ if (!auth) {+ return disabledOptions({+ placeholder: 'Please connect your account first.',+ });+ }+ const spaces = await databricksApi.listGenieSpaces({ auth });+ return {+ disabled: false,+ options: spaces.map((space) => ({+ label: space.title,+ value: space.space_id,+ })),+ placeholder: spaces.length === 0 ? 'No Genie spaces found.' : undefined,+ };+ },+ });+}++function disabledOptions({+ placeholder,+}: {+ placeholder: string;+}): DropdownState<never> {+ return { disabled: true, options: [], placeholder };+}++export const databricksProps = {+ warehouseId,+ catalogName,+ schemaName,+ tableName,+ volumeName,+ columnName,+ rowFields,+ rowList,+ genieSpaceId,+};++export type PropParams<R extends boolean> = {+ required: R;+ displayName?: string;+ description?: string;+};diff --git a/packages/pieces/community/databricks/src/lib/common/types.ts b/packages/pieces/community/databricks/src/lib/common/types.tsnew file mode 100644index 00000000000..8f36e83a114--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/common/types.ts@@ -0,0 +1,109 @@+import type { AppConnectionType } from '@activepieces/pieces-framework';++export type DatabricksCredentials = {+ workspaceUrl: string;+ clientId: string;+ clientSecret: string;+};++export type DatabricksAuthValue = {+ type: AppConnectionType.CUSTOM_AUTH;+ access_token?: string;+ props: DatabricksCredentials;+};++export type DatabricksToken = { access_token: string; expires_in?: number };++export type DatabricksWarehouse = { id: string; name: string; state?: string };++export type DatabricksNamed = { name: string; full_name?: string };++export type DatabricksColumn = {+ name: string;+ type_name?: string;+ type_text?: string;+ nullable?: boolean;+ comment?: string;+};++export type DatabricksTable = DatabricksNamed & {+ columns?: DatabricksColumn[];+};++export type DatabricksGenieSpace = {+ space_id: string;+ title: string;+ description?: string;+};++export type DatabricksFileColumn = { name: string; type_name?: string };++export type DatabricksStatementParameter = { name: string; value?: string };++export type DatabricksStatement = {+ statement_id: string;+ status: { state: string; error?: { error_code?: string; message?: string } };+ manifest?: {+ schema?: { columns?: { name: string; type_name?: string }[] };+ total_row_count?: number;+ truncated?: boolean;+ };+ result?: DatabricksResultChunk;+};++export type DatabricksResultChunk = {+ data_array?: (string | null)[][];+ next_chunk_index?: number;+};++export type DatabricksQueryResult = {+ statementId: string;+ columns: string[];+ rows: Record<string, unknown>[];+ rowCount: number;+ truncated: boolean;+};++export type DatabricksGenieAttachment = {+ attachment_id?: string;+ text?: { content?: string };+ query?: { query?: string; description?: string; title?: string };+};++export type DatabricksGenieMessage = {+ id?: string;+ message_id?: string;+ conversation_id: string;+ status: string;+ attachments?: DatabricksGenieAttachment[];+ error?: { error?: string; type?: string };+};++export type DatabricksPage<K extends string, T> = { [P in K]?: T[] } & {+ next_page_token?: string;+};++export type DatabricksTableLocation = {+ catalogName: string;+ schemaName: string;+ tableName: string;+};++export type DatabricksRowSource = {+ sql: string;+ columnNames: string[];+ parameters: DatabricksStatementParameter[];+};++export type DatabricksGenieAnswer = {+ conversationId: string;+ messageId: string;+ status: string;+ answer: string;+ sql: string | null;+ queryDescription: string | null;+ columns: string[];+ rows: Record<string, unknown>[];+ rowCount: number;+ truncated: boolean;+};diff --git a/packages/pieces/community/databricks/src/lib/common/utils.ts b/packages/pieces/community/databricks/src/lib/common/utils.tsnew file mode 100644index 00000000000..8e82099752b--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/common/utils.ts@@ -0,0 +1,139 @@+import type {+ DatabricksColumn,+ DatabricksRowSource,+ DatabricksTableLocation,+} from './types';++function quoteIdentifier({ name }: { name: string }): string {+ return `\`${name.replace(/`/g, '``')}\``;+}++function tableRef({+ catalogName,+ schemaName,+ tableName,+}: DatabricksTableLocation): string {+ return [catalogName, schemaName, tableName]+ .map((name) => quoteIdentifier({ name }))+ .join('.');+}++function stringLiteral({ value }: { value: string }): string {+ return `'${value.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`;+}++function convertToColumnType({+ column,+ expression,+}: {+ column: DatabricksColumn;+ expression: string;+}): string {+ const typeName = (column.type_name ?? 'STRING').toUpperCase();+ const typeText = column.type_text ?? typeName;+ if (typeName === 'STRING') {+ return expression;+ }+ if (typeName === 'VARIANT') {+ return `parse_json(${expression})`;+ }+ if (COMPLEX_TYPES.includes(typeName)) {+ return `from_json(${expression}, ${stringLiteral({+ value: typeText,+ })}, map('mode', 'FAILFAST'))`;+ }+ return `CAST(${expression} AS ${typeText})`;+}++function toParameterValue({ value }: { value: unknown }): string | undefined {+ if (value === null || value === undefined) {+ return undefined;+ }+ return typeof value === 'object' ? JSON.stringify(value) : String(value);+}++function compactRow({+ row,+}: {+ row: Record<string, unknown>;+}): Record<string, unknown> {+ return Object.fromEntries(+ Object.entries(row).filter(+ ([, value]) => value !== undefined && value !== ''+ )+ );+}++function findColumn({+ columns,+ name,+}: {+ columns: DatabricksColumn[];+ name: string;+}): DatabricksColumn {+ const column = columns.find((c) => c.name === name);+ if (!column) {+ throw new Error(`Column "${name}" was not found in the table.`);+ }+ return column;+}++function buildRowSource({+ columns,+ rows,+}: {+ columns: DatabricksColumn[];+ rows: Record<string, unknown>[];+}): DatabricksRowSource {+ const unknownKeys = [+ ...new Set(rows.flatMap((row) => Object.keys(row))),+ ].filter((key) => !columns.some((c) => c.name === key));+ if (unknownKeys.length > 0) {+ throw new Error(+ `These fields are not columns of the table: ${unknownKeys.join(', ')}`+ );+ }+ const used = columns.filter((column) =>+ rows.some((row) => row[column.name] !== undefined)+ );+ if (used.length === 0) {+ throw new Error('Provide a value for at least one column.');+ }+ const schema = `ARRAY<STRUCT<${used+ .map((column) => `${quoteIdentifier({ name: column.name })}: STRING`)+ .join(', ')}>>`;+ const selectList = used+ .map((column) => {+ const name = quoteIdentifier({ name: column.name });+ return `${convertToColumnType({ column, expression: name })} AS ${name}`;+ })+ .join(', ');+ const payload = rows.map((row) =>+ Object.fromEntries(+ used.map((column) => [+ column.name,+ toParameterValue({ value: row[column.name] }) ?? null,+ ])+ )+ );+ return {+ sql: `SELECT ${selectList} FROM (SELECT inline(from_json(:rows, ${stringLiteral(+ { value: schema }+ )})))`,+ columnNames: used.map((column) => column.name),+ parameters: [{ name: 'rows', value: JSON.stringify(payload) }],+ };+}++export const databricksUtils = {+ quoteIdentifier,+ tableRef,+ stringLiteral,+ convertToColumnType,+ toParameterValue,+ compactRow,+ findColumn,+ buildRowSource,+};++const COMPLEX_TYPES = ['ARRAY', 'MAP', 'STRUCT'];diff --git a/packages/pieces/community/databricks/src/lib/output-schemas.ts b/packages/pieces/community/databricks/src/lib/output-schemas.tsnew file mode 100644index 00000000000..80246d822cb--- /dev/null+++ b/packages/pieces/community/databricks/src/lib/output-schemas.ts@@ -0,0 +1,95 @@+import {+ OutputSchema,+ OutputSchemaField,+} from '@activepieces/pieces-framework';++const rowColumnsField: OutputSchemaField = {+ key: 'columns',+ label: 'Row Columns',+ value: '',+ dynamicKey: true,+};++const statementIdField: OutputSchemaField = {+ key: 'statementId',+ label: 'Statement ID',+};++const affectedRowsField: OutputSchemaField = {+ key: 'num_affected_rows',+ label: 'Rows Affected',+ format: 'number',+};++const insertedRowsField: OutputSchemaField = {+ key: 'num_inserted_rows',+ label: 'Rows Inserted',+ format: 'number',+};++export const queryResultOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'rows',+ label: 'Rows',+ description: 'Each row is an object keyed by column name.',+ listItems: [rowColumnsField],+ },+ { key: 'columns', label: 'Column Names' },+ { key: 'rowCount', label: 'Rows Returned', format: 'number' },+ { key: 'truncated', label: 'Truncated', format: 'boolean' },+ statementIdField,+ ],+};++export const insertResultOutputSchema: OutputSchema = {+ fields: [affectedRowsField, insertedRowsField, statementIdField],+};++export const updateResultOutputSchema: OutputSchema = {+ fields: [affectedRowsField, statementIdField],+};++export const upsertResultOutputSchema: OutputSchema = {+ fields: [+ affectedRowsField,+ insertedRowsField,+ { key: 'num_updated_rows', label: 'Rows Updated', format: 'number' },+ statementIdField,+ ],+};++export const loadFileOutputSchema: OutputSchema = {+ fields: [+ { key: 'filePath', label: 'Volume File Path' },+ affectedRowsField,+ insertedRowsField,+ {+ key: 'num_skipped_corrupt_files',+ label: 'Corrupt Files Skipped',+ format: 'number',+ },+ statementIdField,+ ],+};++export const askGenieOutputSchema: OutputSchema = {+ fields: [+ { key: 'answer', label: 'Answer' },+ { key: 'sql', label: 'Generated SQL' },+ { key: 'queryDescription', label: 'Query Description' },+ {+ key: 'rows',+ label: 'Rows',+ description:+ 'Rows returned by the query Genie ran, keyed by column name.',+ listItems: [rowColumnsField],+ },+ { key: 'columns', label: 'Column Names' },+ { key: 'rowCount', label: 'Rows Returned', format: 'number' },+ { key: 'truncated', label: 'Truncated', format: 'boolean' },+ { key: 'conversationId', label: 'Conversation ID' },+ { key: 'messageId', label: 'Message ID' },+ { key: 'status', label: 'Status' },+ ],+};diff --git a/packages/pieces/community/databricks/tsconfig.json b/packages/pieces/community/databricks/tsconfig.jsonnew file mode 100644index 00000000000..b512ca3708c--- /dev/null+++ b/packages/pieces/community/databricks/tsconfig.json@@ -0,0 +1,19 @@+{+ "extends": "../../../../tsconfig.base.json",+ "compilerOptions": {+ "module": "commonjs",+ "forceConsistentCasingInFileNames": true,+ "strict": true,+ "noImplicitOverride": true,+ "noPropertyAccessFromIndexSignature": true,+ "noImplicitReturns": true,+ "noFallthroughCasesInSwitch": true+ },+ "files": [],+ "include": [],+ "references": [+ {+ "path": "./tsconfig.lib.json"+ }+ ]+}\ No newline at end of filediff --git a/packages/pieces/community/databricks/tsconfig.lib.json b/packages/pieces/community/databricks/tsconfig.lib.jsonnew file mode 100644index 00000000000..312dfdeb31f--- /dev/null+++ b/packages/pieces/community/databricks/tsconfig.lib.json@@ -0,0 +1,21 @@+{+ "extends": "./tsconfig.json",+ "compilerOptions": {+ "rootDir": ".",+ "baseUrl": ".",+ "paths": {},+ "outDir": "./dist",+ "declaration": true,+ "types": [+ "node"+ ]+ },+ "include": [+ "src/**/*.ts"+ ],+ "exclude": [+ "jest.config.ts",+ "src/**/*.spec.ts",+ "src/**/*.test.ts"+ ]+}\ No newline at end of filediff --git a/tsconfig.base.json b/tsconfig.base.jsonindex 6035fb21ba4..0804cdfd5b0 100644--- a/tsconfig.base.json+++ b/tsconfig.base.json@@ -395,6 +395,9 @@"@activepieces/piece-data-summarizer": ["packages/pieces/core/data-summarizer/src/index.ts"],+ "@activepieces/piece-databricks": [+ "packages/pieces/community/databricks/src/index.ts"+ ],"@activepieces/piece-datadog": ["packages/pieces/community/datadog/src/index.ts"],