-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ARRAYLENGTH UDF for multi-valued columns #5301
Conversation
Add description and sample queries please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the name of the transform function pick either array_length or cardinality.
import org.apache.pinot.core.plan.DocIdSetPlanNode; | ||
|
||
|
||
public class LengthTransformFunction extends BaseTransformFunction { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add java docs with a sample query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
|
||
public class LengthTransformFunction extends BaseTransformFunction { | ||
public static final String FUNCTION_NAME = "length"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this applies to multi-valued column, It might be better to name this array_length or cardinality.
https://prestodb.io/docs/current/functions/array.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. Changed this to arrayLength so people do not confuse it with the length function for strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is to support pushdown of Presto SQL's cardinality() function.
Sample queries:
SELECT COUNT(*) FROM table WHERE arrayLength(mvColumn) > 2
SELECT COUNT(*) FROM table GROUP BY arrayLength(mvColumn)
SELECT MAX(arrayLength(mvColumn)) FROM table