Support combining multiple output variables.#737
Support combining multiple output variables.#737nhtruong merged 3 commits intoopensearch-project:mainfrom
Conversation
Changes AnalysisCommit SHA: 43dc5f2 API ChangesSummaryNO CHANGES ReportThe full API changes report is available at: https://github.com/opensearch-project/opensearch-api-specification/actions/runs/12397608942/artifacts/2338846969 API Coverage
|
2990ceb to
3b06ff0
Compare
Spec Test Coverage Analysis
|
|
@nhtruong care to take a look pls? |
| @@ -87,16 +87,42 @@ export enum Result { | |||
| export class OutputReference { | |||
There was a problem hiding this comment.
I missed this when this was first added but this file is meant to hold type definitions only. This class should be in its own file.
| static replace(str: string, callback: (chapter_id: any, variable: any) => string): any { | ||
| // preserve type if 1 value is returned | ||
| let full_match = str.match(/^\$\{([^}]+)\}$/) | ||
| if (full_match) { | ||
| const spl = this.#split(full_match[1], '.', 2) | ||
| return callback(spl[0], spl[1]) | ||
| } else return str.replace(/\$\{([^}]+)\}/g, (_, k) => { | ||
| const spl = this.#split(k, '.', 2) | ||
| return callback(spl[0], spl[1]) | ||
| }); | ||
| } |
There was a problem hiding this comment.
Should add a comment explaining what this function does because it's not clear what it's trying to achieve.
| static #split(str: any, delim: string, count: number): string[] { | ||
| if (str === undefined) return [str] | ||
| if (count <= 0) return [str] | ||
| const parts = str.split(delim) | ||
| if (parts.length <= count) return parts | ||
| const result = parts.slice(0, count - 1) | ||
| result.push(parts.slice(count - 1).join(delim)) | ||
| return result |
There was a problem hiding this comment.
This needs an explanation as well.
| } else { | ||
| return str | ||
| } | ||
| return OutputReference.replace(str, (chapter_id, output_name) => { |
There was a problem hiding this comment.
If this is the only place the replace function is used, then having a generic replace function that can handle any callback is a bit over-engineered, IMO.
There was a problem hiding this comment.
I think it's best we keep the parsing regex values/logic in one place so it doesn't leak into the usage of it.
| expect(OutputReference.replace('string', f)).toEqual('string') | ||
| expect(OutputReference.replace('${k.v}', f)).toEqual('[k:v]') | ||
| expect(OutputReference.replace('${k.value}', f)).toEqual('[k:value]') | ||
| expect(OutputReference.replace('${k.v.m}', f)).toEqual('[k:v.m]') |
There was a problem hiding this comment.
I was on board until the last example. It's not clearly why k is treated differently from v and m and how the callback f caused such an output.
There was a problem hiding this comment.
Our output variables are split with namespace.xyz where namespace=payload and is meaningful, but the rest of it is not and can be anything, including something that contains periods. That's basically what this is testing.
|
|
f632b2a to
c546f0e
Compare
|
Ready to be reviewed again, thanks @nhtruong! |
Signed-off-by: dblock <dblock@amazon.com>
Signed-off-by: dblock <dblock@amazon.com>
Signed-off-by: dblock <dblock@amazon.com>
* Support combining multiple output variables. Signed-off-by: dblock <dblock@amazon.com>
* Support combining multiple output variables. Signed-off-by: dblock <dblock@amazon.com> Signed-off-by: Tokesh <tokesh789@gmail.com>
* adding missing tests Signed-off-by: Tokesh <tokesh789@gmail.com> * fixing validate ci, links, added node failure in specs Signed-off-by: Tokesh <tokesh789@gmail.com> * adding node failures to changelog, fixing path in specs of update by query and small fix in response of query group tests Signed-off-by: Tokesh <tokesh789@gmail.com> * Support combining multiple output variables. (#737) * Support combining multiple output variables. Signed-off-by: dblock <dblock@amazon.com> Signed-off-by: Tokesh <tokesh789@gmail.com> * hotfix of method in snapshots Signed-off-by: Tokesh <tokesh789@gmail.com> * hotfix with snapshot tests Signed-off-by: Tokesh <tokesh789@gmail.com> * hotfix race condition Signed-off-by: Tokesh <tokesh789@gmail.com> * adding chapter in snapshot tests Signed-off-by: Tokesh <tokesh789@gmail.com> * correcting path to repository in snapshot tests Signed-off-by: Tokesh <tokesh789@gmail.com> * adding verbose to check ci Signed-off-by: Tokesh <tokesh789@gmail.com> * deleting verbose Signed-off-by: Tokesh <tokesh789@gmail.com> * added retry to status in snapshots Signed-off-by: Tokesh <tokesh789@gmail.com> * added retry to correct place Signed-off-by: Tokesh <tokesh789@gmail.com> * adding verbose to check Signed-off-by: Tokesh <tokesh789@gmail.com> * renaming to avoid race condition Signed-off-by: Tokesh <tokesh789@gmail.com> * refactoring folder organization, adding retries, fixing naming Signed-off-by: Tokesh <tokesh789@gmail.com> --------- Signed-off-by: Tokesh <tokesh789@gmail.com> Signed-off-by: dblock <dblock@amazon.com> Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> Co-authored-by: Daniel (dB.) Doubrovkine <dblock@amazon.com>
Description
task_id: ${task.node}:${task.id}. I ended up not using this and getting the task ID fromdelete_by_query, but it's a useful feature IMO.Issues Resolved
Part of #663.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.