Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-7740

Parsing of UDF body is broken

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 2.2.0 beta 1
    • None
    • None
    • Normal

    Description

      The parsing of function body introduced by CASSANDRA-7395 is somewhat broken. It blindly parse everything up to END_BODY, which as 2 problems:

      1. it parse function body as if it was part of the CQL syntax, so anything that don't happen to be a valid CQL token won't even parse.
      2. something like
        CREATE FUNCTION foo() RETURNS text LANGUAGE JAVA BODY return "END_BODY"; END_BODY;
        

        will not parse correctly.

      I don't think we can accept random syntax like that. A better solution (which is the one Postgresql uses) is to pass the function body as a normal string. And in fact I'd be in favor of reusing Postgresql syntax (because why not), that is to have:

      CREATE FUNCTION foo() RETURNS text LANGUAGE JAVA AS 'return "END_BODY"';
      

      One minor annoyance might be, for certain languages, the necessity to double every quote inside the string. But in a separate ticket we could introduce Postregsql solution of adding an alternate syntax for string constants.

      Attachments

        1. 7740.txt
          4 kB
          Robert Stupp

        Issue Links

          Activity

            People

              snazy Robert Stupp
              slebresne Sylvain Lebresne
              Robert Stupp
              Sylvain Lebresne
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: