Skip to content

Commit

Permalink
Add multi-checkpoint support to integrations (opensearch-project#1742)
Browse files Browse the repository at this point in the history
* Refactor addIntegrationRequest params to object

Signed-off-by: Simeon Widdis <[email protected]>

* Move SetupIntegrationFormInputs to own file

Signed-off-by: Simeon Widdis <[email protected]>

* Split form inputs into more sections visually

Signed-off-by: Simeon Widdis <[email protected]>

* Split form inputs into more sections logically

Signed-off-by: Simeon Widdis <[email protected]>

* Minor copy update for checkpoint location

Signed-off-by: Simeon Widdis <[email protected]>

* Add UUID to created checkpoint location

Signed-off-by: Simeon Widdis <[email protected]>

* Use dashes instead of underscores for separating checkpoint parts

Signed-off-by: Simeon Widdis <[email protected]>

* Update toggleworkflow method per Ryan's feedback

Signed-off-by: Simeon Widdis <[email protected]>

---------

Signed-off-by: Simeon Widdis <[email protected]>
  • Loading branch information
Swiddis authored Apr 25, 2024
1 parent d131d99 commit 3dbe5c8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion public/components/integrations/components/setup_integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,21 @@ const makeTableName = (config: IntegrationSetupInputs): string => {
};

const prepareQuery = (query: string, config: IntegrationSetupInputs): string => {
// To prevent checkpoint collisions, each query needs a unique checkpoint name, we use an enriched
// UUID to create subfolders under the given checkpoint location per-query.
const querySpecificUUID = crypto.randomUUID();
let checkpointLocation = config.checkpointLocation.endsWith('/')
? config.checkpointLocation
: config.checkpointLocation + '/';
checkpointLocation += `${config.connectionDataSource}-${config.connectionTableName}-${querySpecificUUID}`;

let queryStr = query.replaceAll('{table_name}', makeTableName(config));
queryStr = queryStr.replaceAll('{s3_bucket_location}', config.connectionLocation);
queryStr = queryStr.replaceAll('{s3_checkpoint_location}', config.checkpointLocation);
queryStr = queryStr.replaceAll('{s3_checkpoint_location}', checkpointLocation);
queryStr = queryStr.replaceAll('{object_name}', config.connectionTableName);
// TODO spark API only supports single-line queries, but directly replacing all whitespace leads
// to issues with single-line comments and quoted strings with more whitespace. A more robust
// implementation would remove comments before flattening and ignore strings.
queryStr = queryStr.replaceAll(/\s+/g, ' ');
return queryStr;
};
Expand Down

0 comments on commit 3dbe5c8

Please sign in to comment.