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

Add auto import java.util for UDF code block

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 3.6
    • Legacy/CQL
    • None
    • C* 3.4

    Description

      Right now, when creating Java source code for UDF, since we cannot define import, we need to use fully qualified class name, ex:

      CREATE FUNCTION toSet(li list<text>)
      CALLED ON NULL INPUT
      RETURNS text
      LANGUAGE java
      AS $$
          java.util.Set<String> set = new java.util.HashSet();
          for(String txt: list) {
              set.add(txt);
          }
          return set;
      $$;
      

      Classes from java.util package are so commonly used that it makes developer life easier to import automatically java.util.* in the JavaUDF base class so that developers don't need to use FQCN for common classes.

      The only drawback I can see is the risk of class name clash but since:

      1. it is not allow to create new class
      2. classes that can be used in UDF are restricted

      I don't see serious clash name issues either

      snazy WDYT ?

      Attachments

        1. patch.txt
          2 kB
          DuyHai Doan

        Activity

          People

            doanduyhai DuyHai Doan
            doanduyhai DuyHai Doan
            DuyHai Doan
            Robert Stupp
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: