def resolveChoice()

in awsglue/dynamicframe.py [0:0]


    def resolveChoice(self, specs=None, choice="", database=None, table_name=None,
                      transformation_ctx="", info="", stageThreshold=0, totalThreshold=0, catalog_id=None):
        """
        :param specs: specification for choice type and corresponding resolve action,
                      if the specs is empty, then tape backend would go one round of the data
                      to get schema, and then based on the schema to resolve choice.
        :param choice: default option when choice type path found missing from specs
        :param database: Glue catalog database name, required for MATCH_CATALOG choice
        :param table_name: Glue catalog table name, required for MATCH_CATALOG choice
        :return: a new DynamicFrame
        """
        def _to_java_specs(specs_tup):
            path, action = specs_tup
            return self.glue_ctx._jvm.ResolveSpec.apply(path, action)

        if specs is None and not choice:
            raise Exception("Parameter specs and option are both missing, add one.")

        if specs is not None and choice:
            raise Exception("Parameter specs and option are both specified, choose one.")

        if specs is None:
            specs = []

        if isinstance(specs, tuple):
            specs = [specs]

        specs_list = [ _to_java_specs(m) for m in specs ]

        choice_option = _as_scala_option(self._sc, _as_resolve_choiceOption(self._sc, choice))
        database_option = _as_scala_option(self._sc, database)
        table_name_option = _as_scala_option(self._sc, table_name)

        new_jdf = self._jdf.resolveChoice(
            self.glue_ctx._jvm.PythonUtils.toSeq(specs_list),
            choice_option, database_option, table_name_option,
            transformation_ctx,
            _call_site(self._sc, callsite(), info), long(stageThreshold), long(totalThreshold),
            _as_scala_option(self._sc, catalog_id))

        return DynamicFrame(new_jdf, self.glue_ctx, self.name)