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

Defining UDFs using scripting language directly from CQL

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Fix Version/s: 2.2.0 beta 1
    • Component/s: None
    • Labels:
      None

      Description

      In CASSANDRA-7395 we'll introduce the ability to define user functions by dropping a java class server side. While this is a good first step and a good option to have in any case, it would be nice to provide a simpler way to define those functions directly from CQL. And while we probably don't want to re-invent a new programming language inside CQL, we can reuse one. Typically, with java 8, we could use nashorn. This would allow a syntax along the lines of:

      CREATE FUNCTION sum (a bigint, b bigint) bigint AS { return a + b; }
      

      Note that in this, everything before the AS will be parsed by us, which we'll probably want because we'll probably need to have the types of arguments/return in practice anyway, and it's a good idea to reuse CQL types. The expression after the AS will be given to Nashorn however.

      Please note that in theory we could ultimately support multiple language after the AS. However, I'd like to focus on supporting just one for this ticket and I'm keen on using javascript through Nashorn because as it's the one that will ship with java from now on, it feels like a safe default.

        Attachments

        1. 7526.txt
          7 kB
          Robert Stupp
        2. 7526v2.txt
          7 kB
          Robert Stupp
        3. 7526v3.txt
          13 kB
          Robert Stupp
        4. 7526v4.txt
          13 kB
          Robert Stupp
        5. 7526v5.txt
          22 kB
          Robert Stupp
        6. 7526v6.txt
          20 kB
          Robert Stupp

          Issue Links

            Activity

              People

              • Assignee:
                snazy Robert Stupp
                Reporter:
                slebresne Sylvain Lebresne
                Authors:
                Robert Stupp
                Reviewers:
                Tom Hobbs
                Tester:
                Shawn Kumar
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: