Skip to content

Conversation

@maropu
Copy link
Member

@maropu maropu commented Mar 17, 2015

This is useful for using pre-defined UDFs in SQLContext;

val df = Seq(("id1", 1), ("id2", 4), ("id3", 5)).toDF("id", "value")
val sqlctx = df.sqlContext
sqlctx.udf.register("simpleUdf", (v: Int) => v * v)
df.select($"id", sqlctx.callUdf("simpleUdf", $"value"))

@rxin
Copy link
Contributor

rxin commented Mar 17, 2015

Can't we make this explicit by using "callUDF"?

@maropu
Copy link
Member Author

maropu commented Mar 17, 2015

You mean df.select($"id", callUDF($"value"))?

@rxin
Copy link
Contributor

rxin commented Mar 17, 2015

I meant something like

df.select($"id", callUDF("simpleUDF", $"value"))

@maropu
Copy link
Member Author

maropu commented Mar 18, 2015

Ok, I'll try to refine my codes.

@maropu
Copy link
Member Author

maropu commented Mar 18, 2015

@rxin fixed, and plz check it.

Copy link
Contributor

Choose a reason for hiding this comment

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

This probably belongs in functions.scala with the other callUDF methods. Also, please explicitly specify return types for public methods.

@marmbrus
Copy link
Contributor

Once you have updated, can you also update the PR description, as this becomes the commit message. Thanks!

@maropu maropu changed the title [SPARK-6379][SQL] Support an implicit conversion from udf"name" to an UDF defined in SQLContext [SPARK-6379][SQL] Support a functon to call user-defined functions registered in SQLContext Mar 23, 2015
@maropu maropu force-pushed the SupportUDFConversionInSparkContext branch from bb07c54 to 5929b9f Compare March 23, 2015 03:29
@maropu
Copy link
Member Author

maropu commented Mar 23, 2015

The description updated and the patch fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

This probably belongs in functions.scala with the other callUDF methods.

This is still defined in the wrong file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, misunderstood.
I'll move the function into functions.scala.

@maropu
Copy link
Member Author

maropu commented Mar 26, 2015

Fixed, and plz re-check it.

@maropu maropu force-pushed the SupportUDFConversionInSparkContext branch from 5929b9f to f858aff Compare March 26, 2015 07:33
@marmbrus
Copy link
Contributor

ok to test

@SparkQA
Copy link

SparkQA commented Apr 12, 2015

Test build #30095 has finished for PR 5061 at commit f858aff.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.
  • This patch does not change any dependencies.

@marmbrus
Copy link
Contributor

Thanks! Merged to master.

@asfgit asfgit closed this in 352a5da Apr 12, 2015
@maropu maropu deleted the SupportUDFConversionInSparkContext branch July 5, 2017 11:42
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.

4 participants