Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
Recupera todas as partições da tabela fornecida e atualiza o catálogo.
Sintaxe
recoverPartitions(tableName: str)
Parâmetros
| Parâmetro | Tipo | Descrição |
|---|---|---|
tableName |
str | Nome da tabela a ser obtido. |
Observações
Só funciona com uma tabela particionada e não com uma exibição.
Exemplos
# The example below creates a partitioned table against the existing directory of
# the partitioned table. After that, it recovers the partitions.
import tempfile
with tempfile.TemporaryDirectory(prefix="recoverPartitions") as d:
_ = spark.sql("DROP TABLE IF EXISTS tbl1")
spark.range(1).selectExpr(
"id as key", "id as value").write.partitionBy("key").mode("overwrite").save(d)
_ = spark.sql(
"CREATE TABLE tbl1 (key LONG, value LONG)"
"USING parquet OPTIONS (path '{}') PARTITIONED BY (key)".format(d))
spark.table("tbl1").show()
spark.catalog.recoverPartitions("tbl1")
spark.table("tbl1").show()
# +-----+---+
# |value|key|
# +-----+---+
# +-----+---+
# +-----+---+
# |value|key|
# +-----+---+
# | 0| 0|
# +-----+---+
_ = spark.sql("DROP TABLE tbl1")