[ https://issues.apache.org/jira/browse/CALCITE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16923011#comment-16923011 ]
Julian Hyde commented on CALCITE-222: ------------------------------------- Not surprising. That repo is very old. We migrated the issues to Apache JIRA (keeping the same numbers) so there's no reason to reference the old issues. > 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)