Skip to content

Commit

Permalink
Add ExecutionParameters to AthenaStartQueryExecution
Browse files Browse the repository at this point in the history
Add missing `ExecutionParameters` option to `AthenaStartQueryExecution` step.
  • Loading branch information
nakedible-p authored Sep 25, 2023
1 parent 7670bd1 commit a970f7c
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ const startQueryExecutionJob = new tasks.AthenaStartQueryExecution(this, 'Start
objectKey: 'folder',
},
},
executionParameters: ['param1', 'param2'],
});
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ export interface AthenaStartQueryExecutionProps extends sfn.TaskStateBaseProps {
* @default - No work group
*/
readonly workGroup?: string;

/**
* A list of values for the parameters in a query.
*
* @default - No parameters
*/
readonly executionParameters?: string[];
}

/**
Expand Down Expand Up @@ -209,6 +216,7 @@ export class AthenaStartQueryExecution extends sfn.TaskStateBase {
OutputLocation: this.props.resultConfiguration?.outputLocation ? `s3://${this.props.resultConfiguration.outputLocation.bucketName}/${this.props.resultConfiguration.outputLocation.objectKey}/` : undefined,
},
WorkGroup: this.props?.workGroup,
ExecutionParameters: this.props.executionParameters,
}),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,58 @@ describe('Start Query Execution', () => {
}),
});
});

test('execution parameters', () => {
// GIVEN
const stack = new cdk.Stack();

// WHEN
const task = new AthenaStartQueryExecution(stack, 'Query', {
queryString: 'CREATE DATABASE ?',
clientRequestToken: 'unique-client-request-token',
queryExecutionContext: {
databaseName: 'mydatabase',
catalogName: 'AwsDataCatalog',
},
resultConfiguration: {
outputLocation: {
bucketName: 'query-results-bucket',
objectKey: 'folder',
},
},
workGroup: 'primary',
executionParameters: 'database',
});

// THEN
expect(stack.resolve(task.toStateJson())).toEqual({
Type: 'Task',
Resource: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':states:::athena:startQueryExecution',
],
],
},
End: true,
Parameters: {
QueryString: 'CREATE DATABASE ?',
ClientRequestToken: 'unique-client-request-token',
QueryExecutionContext: {
Database: 'mydatabase',
Catalog: 'AwsDataCatalog',
},
ResultConfiguration: {
OutputLocation: 's3://query-results-bucket/folder/',
},
WorkGroup: 'primary',
ExecutionParameters: ['database'],
},
});
});
});

0 comments on commit a970f7c

Please sign in to comment.