Details

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

      Description

      A table macro is a function that gets executed at prepare time and that generates a relational expression. It can have arguments, as long as those arguments are constants. Views are a special case of table macros - they have no arguments, so can be invoked using the same syntax as regular tables.

      Table macros can be registered programmatically, using `Schema.add(String name, Function function)`, where function implements `TableMacro`.

      Or they can be declared in the schema, using a class that has an `eval` method (static or non-static) declared to return `Table` or a subclass, and that actually return an object that implements `TranslatableTable`. Like this:

      ```json
      {
      version: '1.0',
      schemas: [
      {
      name: 'ADHOC',
      functions: [

      { name: 'MAC', className: 'com.example.MyTableMacro' }

      ]
      }
      ]
      }
      ```

      ```java
      public class MyTableMacro {
      public Table eval(String s) {
      return new TranslatableTable()

      { ... }

      ;
      }
      }
      ```

      ```sql
      SELECT * FROM TABLE(adhoc.mac('a string'));
      ```

      ---------------- Imported from GitHub ----------------
      Url: https://github.com/julianhyde/optiq/issues/222
      Created by: julianhyde
      Labels:
      Created at: Wed Apr 02 08:15:22 CEST 2014
      State: closed

        Activity

        There are no comments yet on this issue.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development