Skip to content

Commit

Permalink
syncing up to f4189819f2641b4fe4748b61c7ad4b5af5884d4b
Browse files Browse the repository at this point in the history
Co-authored-by: Joey Greco <[email protected]>
  • Loading branch information
superblocksadmin and joeyagreco committed Sep 30, 2024
1 parent 9765241 commit 4d38f0e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Update signing rotation endpoint for APIs
- 403 status codes from the server now return as 403 instead of 500
- Added Superblocks partner ID to the Databricks integration

## v1.15.1

Expand Down
36 changes: 6 additions & 30 deletions workers/javascript/packages/plugins/databricks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ interface TableQueryEntity {
}

export default class DatabricksPlugin extends DatabasePluginPooled<DBSQLClient, DatabricksDatasourceConfiguration> {
// This is a NON SECRET id that identifies Superblocks to Databricks for partnership purposes.
private readonly DATABRICKS_PARTNER_CLIENT_ID = 'Superblocks';
pluginName = 'Databricks';
protected readonly parameterType = ':PARAM';
protected readonly columnEscapeCharacter = '`';
Expand Down Expand Up @@ -220,8 +222,6 @@ export default class DatabricksPlugin extends DatabasePluginPooled<DBSQLClient,
});
await client.connect(poolConfig);

this.attachLoggerToClient(client, datasourceConfiguration);

this.logger.debug(`Databricks client connected. ${datasourceConfiguration.connection?.hostUrl}`);
return client;
}
Expand All @@ -237,45 +237,21 @@ export default class DatabricksPlugin extends DatabasePluginPooled<DBSQLClient,
}
}

private attachLoggerToClient(client: DBSQLClient, datasourceConfiguration: DatabricksDatasourceConfiguration) {
if (!datasourceConfiguration.connection) {
return;
}
}

private _validateSQLActionConfigurationForUpdate(actionConfiguration: DatabricksActionConfiguration): void {
if (!actionConfiguration.bulkEdit?.table) {
throw new IntegrationError('Table is required', ErrorCode.INTEGRATION_MISSING_REQUIRED_FIELD, { pluginName: this.pluginName });
}
if (!actionConfiguration.bulkEdit?.schema) {
throw new IntegrationError('Schema is required', ErrorCode.INTEGRATION_MISSING_REQUIRED_FIELD, { pluginName: this.pluginName });
}
if (
!actionConfiguration.bulkEdit.insertedRows &&
!actionConfiguration.bulkEdit.updatedRows &&
!actionConfiguration.bulkEdit.deletedRows
) {
throw new IntegrationError(
'No rows given. Must provide at least one of Inserted Rows, Updated Rows, or Deleted Rows',
ErrorCode.INTEGRATION_MISSING_REQUIRED_FIELD,
{ pluginName: this.pluginName }
);
}
}

private getConnectionConfigFromDatasourceConfiguration(datasourceConfiguration: DatabricksDatasourceConfiguration) {
if (!isEmpty(datasourceConfiguration.connection?.port)) {
return {
host: datasourceConfiguration.connection?.hostUrl as string,
path: datasourceConfiguration.connection?.path as string,
port: datasourceConfiguration.connection?.port as number,
token: datasourceConfiguration.connection?.token as string
token: datasourceConfiguration.connection?.token as string,
clientId: this.DATABRICKS_PARTNER_CLIENT_ID
};
}
return {
host: datasourceConfiguration.connection?.hostUrl as string,
path: datasourceConfiguration.connection?.path as string,
token: datasourceConfiguration.connection?.token as string
token: datasourceConfiguration.connection?.token as string,
clientId: this.DATABRICKS_PARTNER_CLIENT_ID
};
}

Expand Down

0 comments on commit 4d38f0e

Please sign in to comment.