Hi, I'm currently using a combination of TableFunctions and TableMacros to expose various dynamic (relatively unstructured) data sources via Calcite. The underlying data sources are such that data can only be retrieved by first specifying what you want (i.e. there is no catalog of all data that is available).
I'm currently handling this by using a combination of TableFunctions and TableMacros. The issue that I'm running into comes when I want to implement custom planner rules for the underlying functionality. As far I as I can see, it's not possible to register planner rules based on a TableFunctionImpl, because a TableFunctionImpl only exposes a ScannableTable, so there's no chance to hook into RelOptNode.register. On the other hand, implementing a TableMacro does allow to return a TranslatableTable, which then does allow intercepting the call to RelOptNode.register to register rules. However, TableMacros require that all parameters are literals, and I'm providing timestamps, via TIMESTAMPADD() and CURRENT_TIMESTAMP() calls, which then doesn't work for TableMacros (all parameters to a table macro need to be literals, otherwise query validation fails in Calcite). I'm wondering if I'm missing some built-in functionality which would make it possible to have a dynamic table function/macro that can also be manipulated via custom planner rules. Options (which may or may not exist) that I can think of are: * something that would/could visit all macro parameters ahead of time and resolve things like CURRENT_TIMESTAMP() to a literal, before further query validation occurs * register rules somewhere outside of RelOptNode.register (e.g. when the schema is first created) Are there any currently-working options in Calcite that can help me do what I'm trying to do? And if there aren't and I would add such a thing to Calcite, are there any suggestions as to what the most appropriate approach would be (either one of the two options I listed above, or something else)? Thanks, Gabriel
