Re: Acquiring original SQL identifier from RexInputRef

2021-12-21 Thread Jeremy Dyer
Thank you both very much for the feedback. Let me digest this and do some examining of the codebase and will get back with any questions but your responses are very much appreciated. - Jeremy Dyer On Tue, Dec 21, 2021 at 5:28 PM Vladimir Ozerov wrote: > Hi Jeremy, > > There are several solution

Re: Acquiring original SQL identifier from RexInputRef

2021-12-21 Thread Vladimir Ozerov
Hi Jeremy, There are several solutions here. As Jacques mentioned, the popular one is to push the filter/project into the TableScan operator. The critical observations are: 1. SqlNode cannot be linked to RelNode and vice versa in the general case since an optimized relational plan may diffe

Re: Acquiring original SQL identifier from RexInputRef

2021-12-21 Thread Jeremy Dyer
Also, forgive my ignorance but is it possible to get the sort of predicate information I mentioned earlier in this email thread from a SqlNode? I don't see an obvious way in the API but that might solve my use case much easier if possible. On Tue, Dec 21, 2021 at 4:14 PM Jeremy Dyer wrote: > Jac

Re: Acquiring original SQL identifier from RexInputRef

2021-12-21 Thread Jeremy Dyer
Jacques, Interesting ... I'm not familiar with the table scan operator. Is there a good unit test or some example you could point me to using it? Of course doesn't have to be the exact same thing but some sort of example to familiarize myself with the code base there and how I could extend it. - J

Re: Acquiring original SQL identifier from RexInputRef

2021-12-21 Thread Jacques Nadeau
If I understand your situation correctly, I would typically model this as a rule in Calcite that pushes partial predicates (whatever is supported in the underlying library) directly into the table scan operator. At that point, the references are directly related to the original table schema (and th

Re: Acquiring original SQL identifier from RexInputRef

2021-12-21 Thread Jeremy Dyer
Hi Vladimir, I'm certain my design has room for improvement and would love any suggestions. Here is the use case. I'm working on Dask-SQL [1]. We wrap Calcite with a Python layer and use Calcite to parse, validate, and generate relational algebra. From the relational algebra generated we in turn

Re: Acquiring original SQL identifier from RexInputRef

2021-12-21 Thread Vladimir Ozerov
Hi Jeremy, Could you please share the use case behind this requirement? In the general case, it is not possible to link RelNode's attributes to specific identifiers. For this reason, an attempt to extract such identifier from any "rel" except for the RelRoot might indicate a design issue. Regards

Acquiring original SQL identifier from RexInputRef

2021-12-21 Thread Jeremy Dyer
Hello, Is it possible to get the original SQL identifier from an instance of RexInputRef? For example given a simple query like SELECT id FROM employees WHERE fname = 'adam' Instead of the ordinal name generated by RexInputRef ($11, for example). I would like to find the original SQL identifier