Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix topology name and namespace when one of them is an SPL reserved word #2475

Merged
merged 4 commits into from Jun 9, 2020
Merged

Conversation

ghost
Copy link

@ghost ghost commented Jun 9, 2020

resolves #2474
The resolution is, that tokens in the namespace, which are SPL keywords, are replaced by __spl_ + some hash. Name and namespace are manipulated anyway, for example, non-word characters are removed, and empty tokens should be dropped. "Should be", because it did not work.

def _fix_namespace(ns):
    ns = str(ns)
    sns = ns.split('.')
    if len(sns) == 1:
        return re.sub(r'\W+', '', ns, flags=re.UNICODE)
    for i in range(0,len(sns)):
        sns[i] = re.sub(r'\W+', '', sns[i], flags=re.UNICODE)

    for i in range(len(sns), 0):     ## <<< range(len(x), 0) does NO iteration. If it did, next line raised IndexOutOfBounds
        if len(sns[i]) == 0:
            sns.pop(i)

    return '.'.join(sns)

The Java code generation has a test for vaild identifiers regular expression, but does not test for reserved words. As the function is used at many places, I decided, to not touch it.

@markheger markheger merged commit c2cd723 into IBMStreams:master Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jupyter notebooks create invalid SPL code when the project name is a reserved word in SPL
1 participant