Allow Any
type to be used as an escape hatch
#560
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a bug whereby attempting to select two columns of different types following a pick-one-row operation blows up with a type error.
The issue is that when we construct the internal query model node
PickOoneRowPerPatientWithColumns
we collect the selected column objects into a frozenset and make that a node attribute. Then, during type validation, we callget_typespec()
on this attribute to determine its type specification. But this can't cope with sets containing more than one type (e.g.Series[bool]
andSeries[date]
) so it blows up.We could teach
get_typespec()
to be cleverer and work out the common ancestor class for heterogeneous sets like this. But that involves adding complexity to an already very complex system and I'm not sure there's sufficient benefit here. While strict type checking is essential for the public surface of the query model, I don't think it's so essential for the purely internal classes.So instead we just ensure that the
Any
type functions as an escape hatch which shortcuts all the type checking behaviour and change the type annotation of the problematic attribute toAny
.