node.js – How to use a parameter with single quotes in AWS step functions

This is my state

“ExecuteStatement”: {
“Comment”: “Prepare consulta sql a datalake”,
“Next”: “Wait”,
“Parameters”: {
“ClusterIdentifier”: “datalake-redshift-cluster-v2”,
“Database”: “datalake”,
“DbUser”: “epay_reader”,
“Sql.$”: “States.Format(‘SELECT a, b, “c”, d, e, f FROM test WHERE convert_timezone(‘{}’, fecha_1::date)::date = dateadd(day, {}, convert_timezone(‘{}’, sysdate))::date AND 1 IS NOT NULL AND estado = ‘{}’ LIMIT 200;’, ‘America/Santiago’, $.DaysAgo, ‘America/Santiago’,’Authorized’)”
},
“Resource”: “arn:aws:states:::aws-sdk:redshiftdata:executeStatement”,
“Type”: “Task”
}

My Output
{
“resourceType”: “aws-sdk:redshiftdata”,
“resource”: “describeStatement”,
“output”: {
“ClusterIdentifier”: “datalake-redshift-cluster-v2”,
“CreatedAt”: “2023-06-05T23:43:59.090Z”,
“Duration”: -1,
“Error”: “ERROR: column “america” does not exist in vw_reporte_senas_detail”,
“HasResultSet”: false,
“Id”: “40a8ba13-45cb-4ec0-a793-abdafd460f14”,
“QueryString”: “SELECT a, b, “c”, d, e, f FROM test WHERE convert_timezone(America/Santiago, fecha_1::date)::date = dateadd(day, -6, convert_timezone(America/Santiago, sysdate))::date AND fecha_1 IS NOT NULL AND estado_trx = Authorized LIMIT 200;”,
“RedshiftPid”: 1073801635,
“RedshiftQueryId”: -1,
“ResultRows”: -1,
“ResultSize”: -1,
“Status”: “FAILED”,
“UpdatedAt”: “2023-06-05T23:43:59.697Z”
},
“outputDetails”: {
“truncated”: false
}
}

You can see that the replacement is correct but is not included the single quotes’America/Santiago’,’Authorized’ how to add this single quotes?

I try

"ExecuteStatement": { "Comment": "Prepare consulta sql a datalake", "Next": "Wait", "Parameters": { "ClusterIdentifier": "datalake-redshift-cluster-v2", "Database": "datalake", "DbUser": "epay_reader", "Sql.$": "States.Format('SELECT a, b, \"c\", d, e, f FROM test WHERE convert_timezone('{}', fecha_1::date)::date = dateadd(day, {}, convert_timezone('{}', sysdate))::date AND 1 IS NOT NULL AND estado = '{}' LIMIT 200;', 'America/Santiago', $.DaysAgo, 'America/Santiago','Authorized')" }, "Resource": "arn:aws:states:::aws-sdk:redshiftdata:executeStatement", "Type": "Task" }

My output { "resourceType": "aws-sdk:redshiftdata", "resource": "describeStatement", "output": { "ClusterIdentifier": "datalake-redshift-cluster-v2", "CreatedAt": "2023-06-05T23:43:59.090Z", "Duration": -1, "Error": "ERROR: column \"america\" does not exist in vw_reporte_senas_detail", "HasResultSet": false, "Id": "40a8ba13-45cb-4ec0-a793-abdafd460f14", "QueryString": "SELECT a, b, \"c\", d, e, f FROM test WHERE convert_timezone(America/Santiago, fecha_1::date)::date = dateadd(day, -6, convert_timezone(America/Santiago, sysdate))::date AND fecha_1 IS NOT NULL AND estado_trx = Authorized LIMIT 200;", "RedshiftPid": 1073801635, "RedshiftQueryId": -1, "ResultRows": -1, "ResultSize": -1, "Status": "FAILED", "UpdatedAt": "2023-06-05T23:43:59.697Z" }, "outputDetails": { "truncated": false }

Read more here: Source link