-
Notifications
You must be signed in to change notification settings - Fork 28k
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
[SPARK-3904] [SQL] add constant objectinspector support for udfs #2762
Conversation
Can one of the admins verify this patch? |
test this please. |
QA tests have started for PR 2762 at commit
|
QA tests have started for PR 2762 at commit
|
@@ -578,6 +578,7 @@ class HiveCompatibilitySuite extends HiveQueryFileTest with BeforeAndAfter { | |||
"multi_join_union", | |||
"multiMapJoin1", | |||
"multiMapJoin2", | |||
"udf_named_struct", |
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 think you should put it after "udf_month"
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, moved.
QA tests have finished for PR 2762 at commit
|
Test FAILed. |
QA tests have finished for PR 2762 at commit
|
Test FAILed. |
QA tests have started for PR 2762 at commit
|
QA tests have finished for PR 2762 at commit
|
Test FAILed. |
335a952
to
cb97576
Compare
QA tests have started for PR 2762 at commit
|
QA tests have finished for PR 2762 at commit
|
Test PASSed. |
val baseValue = child.eval(input).asInstanceOf[Row] | ||
if (baseValue == null) null else baseValue(ordinal) | ||
val baseValue = child.eval(input) | ||
if (baseValue == null) null else baseValue.asInstanceOf[Row](ordinal) |
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.
Why this change?
cb97576
to
bda7b5a
Compare
Thanks, I've rebased the latest master, and solved the issues you guys raised. |
test this please. |
deferedObjects(i).asInstanceOf[DeferredObjectAdapter].set( | ||
() => { | ||
children(idx).eval(input) | ||
}, argumentInspectors(i)) |
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.
argumentInspector can be set once during deferedObjects creation, rather than execution per row.
unfortunately :( I also have worked and implemented the same as part of #2802 |
Thank you @gvramana , I've updated the code as you suggested. |
retest this please |
QA tests have started for PR 2762 at commit
|
QA tests have finished for PR 2762 at commit
|
test this please |
Test build #22345 has started for PR 2762 at commit
|
Test build #22345 has finished for PR 2762 at commit
|
Test FAILed. |
It passed the unit test in my local with the master rebased. Seems weird. |
retest this please. @liancheng :) |
Test build #490 has started for PR 2762 at commit
|
Also, this needs to be updated again (I think it conflicted with your CTAS patch). |
Test build #490 has finished for PR 2762 at commit
|
…the DeferredObject
782722f
to
bcacfd7
Compare
Rebased! |
test this please |
oi match { | ||
case x: ConstantObjectInspector => x.getWritableConstantValue | ||
case x: PrimitiveObjectInspector => a match { | ||
// TODO what if x.preferWritable() == true? reuse the writable? |
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.
Seems that the Writable
related code was reverted after rebase?
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.
Yes, currently the oi
is should not be "preferWritable" as toInspector
doesn't return that. Even if we return an new instance of Writable
here, it's the same as the preferWritable
ObjectInspector
does internally.
As you suggested we don't want to dynamically check the oi
type, I will keep that for future improvement, and to reuse the writable object.
Test build #22404 has started for PR 2762 at commit
|
Test build #22404 has finished for PR 2762 at commit
|
Test PASSed. |
Thanks for working on this. Merged to master. |
In HQL, we convert all of the data type into normal
ObjectInspector
s for UDFs, most of cases it works, however, some of the UDF actually requires its childrenObjectInspector
to be theConstantObjectInspector
, which will cause exception.e.g.
select named_struct("x", "str") from src limit 1;
I updated the method
wrap
by adding the one more parameterObjectInspector
(to describe what it expects to wrap to, for example: java.lang.Integer or IntWritable).As well as the
unwrap
method by providing the inputObjectInspector
.