Skip to content

[SPARK-3904] [SQL] add constant objectinspector support for udfs - #2762

Closed
chenghao-intel wants to merge 8 commits into
apache:masterfrom
chenghao-intel:udf_coi
Closed

chenghao-intel wants to merge 8 commits into
apache:masterfrom
chenghao-intel:udf_coi

Conversation

@chenghao-intel

Copy link
Copy Markdown
Contributor

In HQL, we convert all of the data type into normal ObjectInspectors for UDFs, most of cases it works, however, some of the UDF actually requires its children ObjectInspector to be the ConstantObjectInspector, 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 parameter ObjectInspector(to describe what it expects to wrap to, for example: java.lang.Integer or IntWritable).

As well as the unwrap method by providing the input ObjectInspector.

@AmplabJenkins

Copy link
Copy Markdown

Can one of the admins verify this patch?

@chenghao-intel

Copy link
Copy Markdown
Contributor Author

test this please.

@SparkQA

SparkQA commented Oct 11, 2014

Copy link
Copy Markdown

QA tests have started for PR 2762 at commit 06581e3.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 11, 2014

Copy link
Copy Markdown

QA tests have started for PR 2762 at commit 06581e3.

  • This patch merges cleanly.

Copy link
Copy Markdown
Contributor

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"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, moved.

@SparkQA

SparkQA commented Oct 11, 2014

Copy link
Copy Markdown

QA tests have finished for PR 2762 at commit 06581e3.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@AmplabJenkins

Copy link
Copy Markdown

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21637/Test FAILed.

@SparkQA

SparkQA commented Oct 11, 2014

Copy link
Copy Markdown

QA tests have finished for PR 2762 at commit 06581e3.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • protected case class Keyword(str: String)
    • class SqlLexical(val keywords: Seq[String]) extends StdLexical
    • case class FloatLit(chars: String) extends Token
    • class SqlParser extends AbstractSparkSQLParser
    • case class SetCommand(kv: Option[(String, Option[String])]) extends Command
    • case class ShellCommand(cmd: String) extends Command
    • case class SourceCommand(filePath: String) extends Command
    • case class SetCommand(kv: Option[(String, Option[String])], output: Seq[Attribute])(

@AmplabJenkins

Copy link
Copy Markdown

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21638/Test FAILed.

@SparkQA

SparkQA commented Oct 11, 2014

Copy link
Copy Markdown

QA tests have started for PR 2762 at commit 335a952.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 11, 2014

Copy link
Copy Markdown

QA tests have finished for PR 2762 at commit 335a952.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@AmplabJenkins

Copy link
Copy Markdown

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21645/Test FAILed.

@SparkQA

SparkQA commented Oct 12, 2014

Copy link
Copy Markdown

QA tests have started for PR 2762 at commit cb97576.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 12, 2014

Copy link
Copy Markdown

QA tests have finished for PR 2762 at commit cb97576.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@AmplabJenkins

Copy link
Copy Markdown

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21661/
Test PASSed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

@chenghao-intel

Copy link
Copy Markdown
Contributor Author

Thanks, I've rebased the latest master, and solved the issues you guys raised.

@chenghao-intel

Copy link
Copy Markdown
Contributor Author

test this please.

Copy link
Copy Markdown
Contributor

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.

@gvramana

Copy link
Copy Markdown
Contributor

unfortunately :( I also have worked and implemented the same as part of #2802
Anyways I will rework on my pull request for supporting UDAF and GenericUDAF, once your changes are merged.

@chenghao-intel

Copy link
Copy Markdown
Contributor Author

Thank you @gvramana , I've updated the code as you suggested.

@chenghao-intel

Copy link
Copy Markdown
Contributor Author

retest this please

@SparkQA

SparkQA commented Oct 20, 2014

Copy link
Copy Markdown

QA tests have started for PR 2762 at commit 49d442b.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 20, 2014

Copy link
Copy Markdown

QA tests have finished for PR 2762 at commit 49d442b.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class DeferredObjectAdapter(oi: ObjectInspector) extends DeferredObject

@tianyi

tianyi commented Oct 22, 2014

Copy link
Copy Markdown
Contributor

Is there any admin could review this PR ASAP? We got some PR blocked by this one. like #2542 @marmbrus @rxin

@liancheng

Copy link
Copy Markdown
Contributor

test this please

@SparkQA

SparkQA commented Oct 28, 2014

Copy link
Copy Markdown

Test build #22345 has started for PR 2762 at commit 782722f.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 28, 2014

Copy link
Copy Markdown

Test build #22345 has finished for PR 2762 at commit 782722f.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class DeferredObjectAdapter(oi: ObjectInspector) extends DeferredObject

@AmplabJenkins

Copy link
Copy Markdown

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/22345/
Test FAILed.

@chenghao-intel

Copy link
Copy Markdown
Contributor Author

It passed the unit test in my local with the master rebased. Seems weird.

@chenghao-intel

Copy link
Copy Markdown
Contributor Author

retest this please. @liancheng :)

@SparkQA

SparkQA commented Oct 28, 2014

Copy link
Copy Markdown

Test build #490 has started for PR 2762 at commit 782722f.

  • This patch merges cleanly.

@marmbrus

Copy link
Copy Markdown
Contributor

Also, this needs to be updated again (I think it conflicted with your CTAS patch).

@SparkQA

SparkQA commented Oct 28, 2014

Copy link
Copy Markdown

Test build #490 has finished for PR 2762 at commit 782722f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class DeferredObjectAdapter(oi: ObjectInspector) extends DeferredObject

@chenghao-intel

Copy link
Copy Markdown
Contributor Author

Rebased!
test this please.

@liancheng

Copy link
Copy Markdown
Contributor

test this please

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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.

@SparkQA

SparkQA commented Oct 29, 2014

Copy link
Copy Markdown

Test build #22404 has started for PR 2762 at commit bcacfd7.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 29, 2014

Copy link
Copy Markdown

Test build #22404 has finished for PR 2762 at commit bcacfd7.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class DeferredObjectAdapter(oi: ObjectInspector) extends DeferredObject

@AmplabJenkins

Copy link
Copy Markdown

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/22404/
Test PASSed.

@marmbrus

Copy link
Copy Markdown
Contributor

Thanks for working on this. Merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants