Add String Column Support for Count Distinct Aggregation #1196
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.
Add String Support for Count Distinct Aggregation
Currently, feathr doesn't support the COUNT_DISTINCT aggregation on string column types, since it assumes the data type from the schema prior to the aggregation. When we try applying COUNT_DISTINCT on string columns, we get this error:
Caused by: Job aborted due to stage failure: Error while encoding: java.lang.RuntimeException: java.lang.Integer is not a valid external type for schema of string
This PR converts each string into a unique 32 bit number using the built in spark hash function such that COUNT_DISTINCT aggregations can also work on string columns.
How was this PR tested?
I ran spark jobs locally and saw them fail before this change, and succeed after this change.
Does this PR introduce any user-facing changes?
COUNT_DISTINCT should now work on string columns.