How can I implement an optional parameter to an AWS Glue Job?
I have created a job that currently have a string parameter (an ISO 8601 date string) as an input that is used in the ETL job. I would like to make this parameter optional, so that the job use a default value if it is not provided (e.g. using datetime.now and datetime.isoformatin my case). I have tried using getResolvedOptions:
import sys
from awsglue.utils import getResolvedOptions
args = getResolvedOptions(sys.argv, ['ISO_8601_STRING'])
However, when I am not passing an --ISO_8601_STRING
job parameter I see the following error:
awsglue.utils.GlueArgumentError: argument --ISO_8601_STRING is required
OPTION_ARG=value
, thevalue
was ignored in preference for the value supplied indefault_optional_args
dictionary. I tweaked you wrapper as follows:supplied = set([i[2:].split('=')[0] for i in sys.argv])
given_optional_fields_key = list((supplied).intersection([i for i in default_optional_args]))
– Mcfarlin