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.
Invalida e atualiza todos os dados armazenados em cache (e os metadados associados) para qualquer DataFrame que contenha o caminho da fonte de dados fornecido.
Sintaxe
refreshByPath(path: str)
Parâmetros
| Parâmetro | Tipo | Descrição |
|---|---|---|
path |
str | O caminho para atualizar o cache. |
Exemplos
# The example below caches a table, and then removes the data.
import tempfile
with tempfile.TemporaryDirectory(prefix="refreshByPath") as d:
_ = spark.sql("DROP TABLE IF EXISTS tbl1")
_ = spark.sql(
"CREATE TABLE tbl1 (col STRING) USING TEXT LOCATION '{}'".format(d))
_ = spark.sql("INSERT INTO tbl1 SELECT 'abc'")
spark.catalog.cacheTable("tbl1")
spark.table("tbl1").show()
# +---+
# |col|
# +---+
# |abc|
# +---+
# Because the table is cached, it computes from the cached data as below.
spark.table("tbl1").count()
# 1
# After refreshing the table by path, it shows 0 because the data does not exist anymore.
spark.catalog.refreshByPath(d)
spark.table("tbl1").count()
# 0
_ = spark.sql("DROP TABLE tbl1")