RFC/WIP: preserve the type of the source upon collect(Enumerable) #3
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.
No user-code workaround for queryverse/Query.jl#157 came to my mind, so I decided to propose a fix.
The first commit just adds
T
param to theEnumerable
, which allows reducingeltype()
redundancy. I think it's a good change overall.The 2nd commit introduces
SimpleSourceEnumerable{T,S}
, which is a type of enumerable that have a single source and doesn't transform elements, e.g. "where" and "orderby".The 3rd commits actually allows
SimpleSourceEnumerable
to preserve the type of theAbstractArray
source uponcollect()
, which covers theCategoricalArray
case without requiring CategoricalArrays dependency.Actually, it would make sense to try to preserve the source type for the other enumerables if the sink is of the same/similar type as the source(s).
Even if the elements are transformed, but the result is
CategoricalValue
, it would make sense to collect them intoCategoricalArray
.But that would require more general design or package dependency decisions.