Calcite relational expressions can represent SELECT, INSERT etc. but not procedural code. It’s a direction we could consider going.
RexProgram is the closest thing we currently have to procedural code in the algebra - single assignment of variables, use of variables in expressions assigning to other variables - but it is a long way short because there are no loops. > On Apr 19, 2020, at 12:47 PM, Ravi Kapoor <[email protected]> wrote: > > Hi Team, > > I have my use where I need to convert my dialect specific stored procedure > constructs like while loop, If then else to Rel expression > > Basically this can contain control flow statements like below > > DECLARE heads BOOL; > DECLARE heads_count INT64 DEFAULT 0; > LOOP > SET heads = RAND() < 0.5; > IF heads THEN > SELECT 'Heads!'; > SET heads_count = heads_count + 1; > ELSE > SELECT 'Tails!'; > BREAK; > END IF; > END LOOP; > SELECT CONCAT(CAST(heads_count AS STRING), ' heads in a row'); > > > I can create a Java AST model from the linq4j provided by calcite however > this is only going to generate Java Result and I believe its only used by > the calcite for relational expressions of enumerable calling convention > which is used by adapters which does not support core relational operations > right? > > Is there a way I can convert the stored proc constructs into some canonical > form like Rel Tree and back to Stored proc of target dialect. > -- > > Thanks, > Ravi
