Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-237

Allow user-defined aggregate functions (UDAs) to be defined in a model


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:


      Allow user-defined aggregate functions (UDAs) to be defined in a model, using a simple class to implement the UDA.

      A class can implement a UDA if it has init and add methods, and optionally initAdd, merge and result. For example,

      class MySumAggFun {
      public MySumAggFun() {}
      public long[] init();
      public long[] initAdd(int v);
      public void add(long[] accumulator, int v);
      public long[] merge(long[] accumulator0, long[] accumulator1);
      public long result(long[] accumulator);

      Every UDA has argument types (in general it can be a list with 0 or more elements, but usually 1), accumulator type, and result type. These are inferred from the method signatures.

      In this example, the accumulator type is `long[]`, the argument type is `[int]`, and the result type is `long`.

      If there is no `result` method, the accumulator and result types are the same, and the result is just the accumulator.

      If there is no `initAdd` method, Optiq calls `init` followed by `add`.

      The methods can all be static, in which case the class does not need a public zero-argument constructor.

      Example model:

      schemas: {
      name: ‘HR’,
      functions: [

      { name: ‘MY_SUM’, className: ‘com.example.MySumAggFun’ }


      ---------------- Imported from GitHub ----------------
      Url: https://github.com/julianhyde/optiq/issues/237
      Created by: julianhyde
      Created at: Sun Apr 06 23:31:50 CEST 2014
      State: closed




            • Assignee:
              github-import GitHub Import
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: