You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Water Cut Off (Jira)" <ji...@apache.org> on 2019/08/28 09:56:00 UTC

[jira] [Commented] (CALCITE-222) User-defined table macros

    [ https://issues.apache.org/jira/browse/CALCITE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16917615#comment-16917615 ] 

Water Cut Off commented on CALCITE-222:
---------------------------------------

[~julianhyde] ,[https://github.com/julianhyde/optiq/issues/222] is 404

> User-defined table macros
> -------------------------
>
>                 Key: CALCITE-222
>                 URL: https://issues.apache.org/jira/browse/CALCITE-222
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: GitHub Import
>            Priority: Major
>              Labels: github-import
>
> 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|https://github.com/julianhyde]
> Labels: 
> Created at: Wed Apr 02 08:15:22 CEST 2014
> State: closed



--
This message was sent by Atlassian Jira
(v8.3.2#803003)