def udf_string_list_str_to_list()

in utilities/Hive_metastore_migration/src/hive_metastore_migration.py [0:0]


    def udf_string_list_str_to_list(str):
        """
        udf_string_list_str_to_list, transform string of a specific format into an array
        :param str: array represented as a string, format should be '<len>%['ele1', 'ele2', 'ele3']'
        :return: array, in this case would be [ele1, ele2, ele3]
        """
        try:
            r = re.compile("\d%\[('\w+',?\s?)+\]")
            if r.match(str) is None:
                return []
            return [s.strip()[1:-1] for s in str.split('%')[1][1:-1].split(',')]
        except (IndexError, AssertionError):
            return []