नोट
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप साइन इन करने या निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
Calls a method with reflection.
Syntax
from pyspark.sql import functions as sf
sf.java_method(*cols)
Parameters
| Parameter | Type | Description |
|---|---|---|
cols |
pyspark.sql.Column or str |
The first element should be a Column representing literal string for the class name, and the second element should be a Column representing literal string for the method name, and the remaining are input arguments (Columns or column names) to the Java method. |
Examples
Example 1: Reflecting a method call with a column argument
from pyspark.sql import functions as sf
spark.range(1).select(
sf.java_method(
sf.lit("java.util.UUID"),
sf.lit("fromString"),
sf.lit("a5cf6c42-0c85-418f-af6c-3e4e5b1328f2")
)
).show(truncate=False)
+-----------------------------------------------------------------------------+
|java_method(java.util.UUID, fromString, a5cf6c42-0c85-418f-af6c-3e4e5b1328f2)|
+-----------------------------------------------------------------------------+
|a5cf6c42-0c85-418f-af6c-3e4e5b1328f2 |
+-----------------------------------------------------------------------------+
Example 2: Reflecting a method call with a column name argument
from pyspark.sql import functions as sf
df = spark.createDataFrame([('a5cf6c42-0c85-418f-af6c-3e4e5b1328f2',)], ['a'])
df.select(
sf.java_method(sf.lit('java.util.UUID'), sf.lit('fromString'), 'a')
).show(truncate=False)
+------------------------------------------+
|java_method(java.util.UUID, fromString, a)|
+------------------------------------------+
|a5cf6c42-0c85-418f-af6c-3e4e5b1328f2 |
+------------------------------------------+