What is a proper way to associate an AggregateCall
that is part of a HAVING
expression with a corresponding field in a RelRecordType
for the LogicalAggregate
? If the AggregateCall
is not part of the SELECT
clause, the LogicalAggregate
's RelRecordType
still has it, but the AggregateCall
's name
attribute is set to NULL
and RelRecordType.getField(AggregateCall.getName())
can't be used in this case. If the AggregateCall
is a part of the final output, its name
is set and RelRecordType.getField(AggregateCall.getName())
returns the right field.
Asked
Active
Viewed 134 times
0

Michael Mior
- 28,107
- 9
- 89
- 113

Michael Alexeev
- 91
- 1
- 2
1 Answers
1
Use field ordinals rather than names.
In the world of Calcite RelNode
s and RexNode
s, field names are not that important; they exist mainly to help you understand the purpose of fields when debugging. Names of AggregateCall
s are even less important; they exist so that Aggregate
can give reasonable names to its fields, and if they don't exist, that's fine.
If your SELECT
has N fields (numbered 0 .. N-1) and a HAVING
clause, you will likely add the HAVING
predicate as field N, apply a Filter
relational operator, then apply a Project
so that only fields 0 .. N-1 are returned. I'm pretty sure that this is what SqlToRelConverter
does already.

Julian Hyde
- 1,239
- 7
- 10