Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6a9646c

Browse files
committed
fix(databricks): addressed requested changes
1 parent 9292e93 commit 6a9646c

File tree

12 files changed

+320
-60
lines changed

12 files changed

+320
-60
lines changed

components/databricks/actions/create-sql-warehouse/create-sql-warehouse.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ export default {
1717
type: "string",
1818
label: "Cluster Size",
1919
description: "Size of the cluster (e.g., `Small`, `Medium`, `Large`)",
20+
options: [
21+
"Small",
22+
"Medium",
23+
"Large",
24+
],
2025
},
2126
autoStopMinutes: {
2227
type: "integer",

components/databricks/actions/delete-sql-warehouse/delete-sql-warehouse.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ export default {
99
props: {
1010
databricks,
1111
warehouseId: {
12-
type: "string",
13-
label: "Warehouse ID",
1412
description: "The ID of the SQL Warehouse to delete",
13+
propDefinition: [
14+
databricks,
15+
"warehouseId",
16+
],
1517
},
1618
},
1719
async run({ $ }) {

components/databricks/actions/edit-sql-warehouse/edit-sql-warehouse.mjs

Lines changed: 118 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,132 @@ export default {
99
props: {
1010
databricks,
1111
warehouseId: {
12-
type: "string",
13-
label: "Warehouse ID",
1412
description: "The ID of the SQL Warehouse to edit",
13+
propDefinition: [
14+
databricks,
15+
"warehouseId",
16+
],
17+
},
18+
name: {
19+
type: "string",
20+
label: "Warehouse Name",
21+
description: "Logical name for the warehouse. Must be unique within an org and under 100 characters.",
22+
optional: true,
23+
},
24+
clusterSize: {
25+
type: "string",
26+
label: "Cluster Size",
27+
description: "Size of clusters allocated for this warehouse.",
28+
options: [
29+
"2X-Small",
30+
"X-Small",
31+
"Small",
32+
"Medium",
33+
"Large",
34+
"X-Large",
35+
"2X-Large",
36+
"3X-Large",
37+
"4X-Large",
38+
],
39+
optional: true,
40+
},
41+
autoStopMins: {
42+
type: "integer",
43+
label: "Auto Stop (minutes)",
44+
description: "Minutes of inactivity before auto-stop. 0 disables autostop. Must be 0 or ≥ 10.",
45+
optional: true,
46+
},
47+
minNumClusters: {
48+
type: "integer",
49+
label: "Min Number of Clusters",
50+
description: "Minimum number of available clusters (> 0 and ≤ min(max_num_clusters, 30)).",
51+
optional: true,
52+
},
53+
maxNumClusters: {
54+
type: "integer",
55+
label: "Max Number of Clusters",
56+
description: "Maximum number of clusters for autoscaler (≥ min_num_clusters and ≤ 30).",
57+
optional: true,
58+
},
59+
enablePhoton: {
60+
type: "boolean",
61+
label: "Enable Photon",
62+
description: "Use Photon optimized clusters.",
63+
optional: true,
64+
},
65+
enableServerlessCompute: {
66+
type: "boolean",
67+
label: "Enable Serverless Compute",
68+
description: "Use serverless compute for this warehouse.",
69+
optional: true,
1570
},
16-
body: {
71+
warehouseType: {
72+
type: "string",
73+
label: "Warehouse Type",
74+
description: "Set to PRO (recommended) or CLASSIC. Set PRO + enable serverless to use serverless.",
75+
options: [
76+
"TYPE_UNSPECIFIED",
77+
"CLASSIC",
78+
"PRO",
79+
],
80+
optional: true,
81+
},
82+
spotInstancePolicy: {
83+
type: "string",
84+
label: "Spot Instance Policy",
85+
description: "Whether the warehouse should use spot instances.",
86+
options: [
87+
"POLICY_UNSPECIFIED",
88+
"COST_OPTIMIZED",
89+
"RELIABILITY_OPTIMIZED",
90+
],
91+
optional: true,
92+
},
93+
tags: {
94+
type: "object",
95+
label: "Tags",
96+
description: "Key-value tags for all resources associated with this warehouse (fewer than 45 tags).",
97+
optional: true,
98+
},
99+
channel: {
17100
type: "object",
18-
label: "Edit Configuration",
19-
description: "The new configuration for the SQL Warehouse (JSON object). Example: `{ \"name\": \"Updated Warehouse\", \"cluster_size\": \"2X-Small\" }`",
101+
label: "Channel",
102+
description: "Channel details. Example: `{ \"name\": \"CHANNEL_NAME_CURRENT\", \"dbsql_version\": \"2023.35\" }`",
103+
optional: true,
104+
},
105+
creatorName: {
106+
type: "string",
107+
label: "Creator Name",
108+
description: "Warehouse creator name.",
109+
optional: true,
110+
},
111+
instanceProfileArn: {
112+
type: "string",
113+
label: "Instance Profile ARN (Deprecated)",
114+
description: "Deprecated. Instance profile used to pass IAM role to the cluster.",
115+
optional: true,
20116
},
21117
},
22118
async run({ $ }) {
119+
const payload = {};
120+
if (this.name) payload.name = this.name;
121+
if (this.clusterSize) payload.cluster_size = this.clusterSize;
122+
if (this.autoStopMins) payload.auto_stop_mins = this.autoStopMins;
123+
if (this.minNumClusters) payload.min_num_clusters = this.minNumClusters;
124+
if (this.maxNumClusters) payload.max_num_clusters = this.maxNumClusters;
125+
if (this.enablePhoton) payload.enable_photon = this.enablePhoton;
126+
if (this.enableServerlessCompute){
127+
payload.enable_serverless_compute = this.enableServerlessCompute;
128+
}
129+
if (this.warehouseType) payload.warehouse_type = this.warehouseType;
130+
if (this.spotInstancePolicy) payload.spot_instance_policy = this.spotInstancePolicy;
131+
if (this.tags) payload.tags = this.tags;
132+
if (this.channel) payload.channel = this.channel;
133+
if (this.creatorName) payload.creator_name = this.creatorName;
134+
if (this.instanceProfileArn) payload.instance_profile_arn = this.instanceProfileArn;
23135
const response = await this.databricks.editSQLWarehouse({
24136
warehouseId: this.warehouseId,
25-
data: this.body,
137+
data: payload,
26138
$,
27139
});
28140

components/databricks/actions/get-sql-warehouse-permissions/get-sql-warehouse-permissions.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ export default {
99
props: {
1010
databricks,
1111
warehouseId: {
12-
type: "string",
13-
label: "Warehouse ID",
1412
description: "The ID of the SQL Warehouse to fetch permissions for",
13+
propDefinition: [
14+
databricks,
15+
"warehouseId",
16+
],
1517
},
1618
},
1719
async run({ $ }) {

components/databricks/actions/get-sql-warehouse/get-sql-warehouse.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ export default {
99
props: {
1010
databricks,
1111
warehouseId: {
12-
type: "string",
13-
label: "Warehouse ID",
1412
description: "The ID of the SQL Warehouse to retrieve",
13+
propDefinition: [
14+
databricks,
15+
"warehouseId",
16+
],
1517
},
1618
},
1719
async run({ $ }) {

components/databricks/actions/list-sql-warehouses/list-sql-warehouses.mjs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,9 @@ export default {
88
type: "action",
99
props: {
1010
databricks,
11-
maxResults: {
12-
type: "integer",
13-
label: "Max Results",
14-
description: "Maximum number of warehouses to return",
15-
default: 50,
16-
optional: true,
17-
},
1811
},
1912
async run({ $ }) {
20-
const params = {
21-
limit: this.maxResults || 50,
22-
};
23-
2413
const { warehouses } = await this.databricks.listSQLWarehouses({
25-
params,
2614
$,
2715
});
2816

components/databricks/actions/set-sql-warehouse-config/set-sql-warehouse-config.mjs

Lines changed: 144 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,155 @@ export default {
88
type: "action",
99
props: {
1010
databricks,
11-
config: {
11+
instanceProfileArn: {
12+
type: "string",
13+
label: "Instance Profile ARN",
14+
description: "Instance profile ARN used to pass an IAM role to clusters (AWS).",
15+
optional: true,
16+
},
17+
googleServiceAccount: {
18+
type: "string",
19+
label: "Google Service Account",
20+
description: "Service account email used for GCP workspaces, if applicable.",
21+
optional: true,
22+
},
23+
securityPolicy: {
24+
type: "string",
25+
label: "Security Policy",
26+
description: "Workspace-wide security policy for SQL Warehouses (if applicable).",
27+
options: [
28+
"NONE",
29+
"DATA_ACCESS_CONTROL",
30+
"PASSTHROUGH",
31+
],
32+
optional: true,
33+
},
34+
channel: {
1235
type: "object",
13-
label: "Configuration",
14-
description: "The configuration object for SQL Warehouses. Example: `{ \"enable_serverless_compute\": true }`",
36+
label: "Channel",
37+
description: "Channel details. Example: `{ \"name\": \"CHANNEL_NAME_PREVIEW\", \"dbsql_version\": \"2023.35\" }`",
38+
optional: true,
39+
},
40+
enabledWarehouseTypes: {
41+
type: "object[]",
42+
label: "Enabled Warehouse Types",
43+
description: "Specify which warehouse types are enabled. Example item: `{ \"warehouse_type\": \"PRO\", \"enabled\": true }`",
44+
properties: {
45+
warehouse_type: {
46+
type: "string",
47+
label: "Warehouse Type",
48+
options: [
49+
"TYPE_UNSPECIFIED",
50+
"CLASSIC",
51+
"PRO",
52+
],
53+
},
54+
enabled: {
55+
type: "boolean",
56+
label: "Enabled",
57+
},
58+
},
59+
optional: true,
60+
},
61+
configParam: {
62+
type: "object[]",
63+
label: "Config Parameters",
64+
description: "General config key/value pairs. Example item: `{ \"key\": \"some.config\", \"value\": \"true\" }`",
65+
properties: {
66+
key: {
67+
type: "string",
68+
label: "Key",
69+
},
70+
value: {
71+
type: "string",
72+
label: "Value",
73+
},
74+
},
75+
optional: true,
76+
},
77+
globalParam: {
78+
type: "object[]",
79+
label: "Global Parameters",
80+
description: "Global config key/value pairs applied to all warehouses.",
81+
properties: {
82+
key: {
83+
type: "string",
84+
label: "Key",
85+
},
86+
value: {
87+
type: "string",
88+
label: "Value",
89+
},
90+
},
91+
optional: true,
92+
},
93+
sqlConfigurationParameters: {
94+
type: "object[]",
95+
label: "SQL Configuration Parameters",
96+
description: "SQL-specific configuration key/value pairs.",
97+
properties: {
98+
key: {
99+
type: "string",
100+
label: "Key",
101+
},
102+
value: {
103+
type: "string",
104+
label: "Value",
105+
},
106+
},
107+
optional: true,
108+
},
109+
dataAccessConfig: {
110+
type: "object[]",
111+
label: "Data Access Config",
112+
description: "Key/value pairs for data access configuration (e.g., credentials passthrough, external storage access).",
113+
properties: {
114+
key: {
115+
type: "string",
116+
label: "Key",
117+
},
118+
value: {
119+
type: "string",
120+
label: "Value",
121+
},
122+
},
123+
optional: true,
15124
},
16125
},
17126
async run({ $ }) {
127+
const payload = {};
128+
129+
if (this.instanceProfileArn) payload.instance_profile_arn = this.instanceProfileArn;
130+
if (this.googleServiceAccount) payload.google_service_account = this.googleServiceAccount;
131+
if (this.securityPolicy) payload.security_policy = this.securityPolicy;
132+
if (this.channel) payload.channel = this.channel;
133+
134+
if (Array.isArray(this.enabledWarehouseTypes) && this.enabledWarehouseTypes.length) {
135+
payload.enabled_warehouse_types = this.enabledWarehouseTypes.map((item) => ({
136+
warehouse_type: item.warehouse_type,
137+
enabled: Boolean(item.enabled),
138+
}));
139+
}
140+
if (Array.isArray(this.configParam) && this.configParam.length) {
141+
payload.config_param = {
142+
configuration_pairs: this.configParam,
143+
};
144+
}
145+
if (Array.isArray(this.globalParam) && this.globalParam.length) {
146+
payload.global_param = {
147+
configuration_pairs: this.globalParam,
148+
};
149+
}
150+
if (Array.isArray(this.sqlConfigurationParameters) && this.sqlConfigurationParameters.length) {
151+
payload.sql_configuration_parameters = {
152+
configuration_pairs: this.sqlConfigurationParameters,
153+
};
154+
}
155+
if (Array.isArray(this.dataAccessConfig) && this.dataAccessConfig.length) {
156+
payload.data_access_config = this.dataAccessConfig;
157+
}
18158
const response = await this.databricks.setSQLWarehouseConfig({
19-
data: this.config,
159+
data: payload,
20160
$,
21161
});
22162

0 commit comments

Comments
 (0)