-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-4233] [SQL] WIP:Simplify the UDAF API (Interface) #3247
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,12 @@ trait FunctionRegistry { | |
|
||
def registerFunction(name: String, builder: FunctionBuilder): Unit | ||
|
||
def lookupFunction(name: String, children: Seq[Expression]): Expression | ||
|
||
def caseSensitive: Boolean | ||
|
||
def lookupFunction( | ||
name: String, | ||
children: Seq[Expression], | ||
distinct: Boolean = false): Expression | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to have careful considerations on this change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but we couldn't tell if it's the UDF or UDAF, except the catalog itself. Any better idea on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I have not a smart idea. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Spark SQL, we put everything about the expression, as its constructor argument list, but Hive requires some additional object to keep the expression info, and both of them will be initialized/used within the executors. We need to throw exception if it's not an UDAF once |
||
} | ||
|
||
trait OverrideFunctionRegistry extends FunctionRegistry { | ||
|
@@ -39,8 +42,13 @@ trait OverrideFunctionRegistry extends FunctionRegistry { | |
functionBuilders.put(name, builder) | ||
} | ||
|
||
abstract override def lookupFunction(name: String, children: Seq[Expression]): Expression = { | ||
functionBuilders.get(name).map(_(children)).getOrElse(super.lookupFunction(name, children)) | ||
abstract override def lookupFunction( | ||
name: String, | ||
children: Seq[Expression], | ||
distinct: Boolean = false): Expression = { | ||
functionBuilders.get(name) | ||
.map(_(children)) | ||
.getOrElse(super.lookupFunction(name, children, distinct)) | ||
} | ||
} | ||
|
||
|
@@ -51,7 +59,10 @@ class SimpleFunctionRegistry(val caseSensitive: Boolean) extends FunctionRegistr | |
functionBuilders.put(name, builder) | ||
} | ||
|
||
override def lookupFunction(name: String, children: Seq[Expression]): Expression = { | ||
override def lookupFunction( | ||
name: String, | ||
children: Seq[Expression], | ||
distinct: Boolean = false): Expression = { | ||
functionBuilders(name)(children) | ||
} | ||
} | ||
|
@@ -65,7 +76,10 @@ object EmptyFunctionRegistry extends FunctionRegistry { | |
throw new UnsupportedOperationException | ||
} | ||
|
||
override def lookupFunction(name: String, children: Seq[Expression]): Expression = { | ||
def lookupFunction( | ||
name: String, | ||
children: Seq[Expression], | ||
distinct: Boolean = false): Expression = { | ||
throw new UnsupportedOperationException | ||
} | ||
|
||
|
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.
This changes must be needed for this patch?
The interfaces of
Row
are related to all the other operator.I think that if necessary, you make a PR first to add these interfaces in
Row
.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.
I agree with that.