Pular para o conteúdo principal

termina com

Retorna um valor booleano. O valor é Verdadeiro se a string terminar com o sufixo. Retorna NULL se qualquer uma das expressões de entrada for NULL. Caso contrário, retorna Falso. Tanto a string (str) quanto o sufixo devem ser do tipo string ou BINARY.

Para a função Databricks SQL correspondente, consulte a funçãoendswith.

Sintaxe

Python
from pyspark.databricks.sql import functions as dbf

dbf.endswith(str=<str>, suffix=<suffix>)

Parâmetros

Parâmetro

Tipo

Descrição

str

pyspark.sql.Column ou str

Uma coluna de strings.

suffix

pyspark.sql.Column ou str

Uma coluna de strings, o sufixo.

Exemplos

Python
df = spark.createDataFrame([("Spark SQL", "Spark",)], ["a", "b"])
df.select(endswith(df.a, df.b).alias('r')).collect()
Output
[Row(r=False)]
Python
df = spark.createDataFrame([("414243", "4243",)], ["e", "f"])
df = df.select(to_binary("e").alias("e"), to_binary("f").alias("f"))
df.printSchema()
df.select(endswith("e", "f"), endswith("f", "e")).show()
Output
root |-- e: binary (nullable = true) |-- f: binary (nullable = true)
+--------------+--------------+
|endswith(e, f)|endswith(f, e)|
+--------------+--------------+
| true| false|
+--------------+--------------+