feat(stepfunctions): allow intrinsic functions for json path#15320
feat(stepfunctions): allow intrinsic functions for json path#15320mergify[bot] merged 7 commits intoaws:masterfrom
Conversation
5f7d61d to
df78631
Compare
|
@BenChaimberg - is this something you can look at? Without this feature it seems hard to have any dynamic behavior with Query Tasks? |
| }); | ||
| ``` | ||
|
|
||
| You can also use [intrinsic functions](https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html) with `JsonPath.stringAt()`. |
There was a problem hiding this comment.
I think it's definitely a good thing that we're unblocking the use of intrinsic functions, I'm just hesitant to advertise JsonPath.stringAt as the entry point. However, I'm not sure if there's a better way without a full design of how to model intrinsic functions properly within the CDK. Any thoughts on a better way to present this to the user as a stopgap until that design takes place?
There was a problem hiding this comment.
@BenChaimberg right, this doesn't feel like the correct long-term solution but I think it's important to unblock this. Can we add a todo somewhere in the code or docs?
| && !path.startsWith('States.Format') | ||
| && !path.startsWith('States.StringToJson') | ||
| && !path.startsWith('States.JsonToString') | ||
| && !path.startsWith('States.Array') |
There was a problem hiding this comment.
I think an array-based condition might be better long term, something like
| && !path.startsWith('States.Format') | |
| && !path.startsWith('States.StringToJson') | |
| && !path.startsWith('States.JsonToString') | |
| && !path.startsWith('States.Array') | |
| && ['Format', 'StringToJson', 'JsonToString', 'Array'].every(fn => !path.startsWith(`States.${fn}`)) |
eacfea3 to
59cd4c5
Compare
Pull request has been modified.
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
`QueryString` can start with an [intrinsic function](https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html). Here is an example of a working `QueryString`: ``` "QueryString.$": "States.Format('select contact_id from interactions.conversation where case when \\'{}\\' is not null then bu=\\'{}\\' else 1=1 end and case when \\'{}\\' is not null then channel=\\'{}\\' else 1=1 end and case when {} is not null then year={} else 1=1 end and case when {} is not null then month={} else 1=1 end and case when {} is not null then day={} else 1=1 end limit 1;', States.JsonToString($.completed), $.partitions.bu, $.partitions.bu, $.partitions.channel, $.partitions.channel, $.partitions.year, $.partitions.year, $.partitions.month, $.partitions.month, $.partitions.day, $.partitions.day)" ```
|
Is there concern that the fix being unintuitive? Would it be better to create a new function for this? |
|
Yes, absolutely, we should support this in a more fluent way. However, this change unblocks usage which is more important at this stage |
`QueryString` can start with an [intrinsic function](https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html). Here is an example of a working `QueryString`: ``` "QueryString.$": "States.Format('select contact_id from interactions.conversation where case when \\'{}\\' is not null then bu=\\'{}\\' else 1=1 end and case when \\'{}\\' is not null then channel=\\'{}\\' else 1=1 end and case when {} is not null then year={} else 1=1 end and case when {} is not null then month={} else 1=1 end and case when {} is not null then day={} else 1=1 end limit 1;', States.JsonToString($.completed), $.partitions.bu, $.partitions.bu, $.partitions.channel, $.partitions.channel, $.partitions.year, $.partitions.year, $.partitions.month, $.partitions.month, $.partitions.day, $.partitions.day)" ```
This adds support for States.JsonMerge, States.ArrayPartition, States.ArrayContains, States.ArrayRange, States.ArrayGetItem, States.ArrayLength, States.ArrayUnique, States.Base64Encode, States.Base64Decode, States.Hash, States.MathRandom, States.MathAdd, States.StringSplit, and States.UUID Builds on top of aws#15320
|
Does this change allow me to use |
QueryStringcan start with an intrinsic function.Here is an example of a working
QueryString: