pyspark.sql.functions.xpath_long#

pyspark.sql.functions.xpath_long(xml, path)[source]#

Returns a long integer value, or the value zero if no match is found, or a match is found but the value is non-numeric.

New in version 3.5.0.

Examples

>>> from pyspark.sql import functions as sf
>>> df = spark.createDataFrame([('<a><b>1</b><b>2</b></a>',)], ['x'])
>>> df.select(sf.xpath_long(df.x, sf.lit('sum(a/b)'))).show()
+-----------------------+
|xpath_long(x, sum(a/b))|
+-----------------------+
|                      3|
+-----------------------+