Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Invalida y actualiza todos los datos almacenados en caché y los metadatos de la tabla especificada.
Sintaxis
refreshTable(tableName: str)
Parámetros
| Parámetro | Tipo | Descripción |
|---|---|---|
tableName |
str | Nombre de la tabla que se va a obtener. Se puede calificar con el nombre del catálogo. |
Ejemplos
# The example below caches a table, and then removes the data.
import tempfile
with tempfile.TemporaryDirectory(prefix="refreshTable") 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, it shows 0 because the data does not exist anymore.
spark.catalog.refreshTable("tbl1")
spark.table("tbl1").count()
# 0
# Using the fully qualified name for the table.
spark.catalog.refreshTable("spark_catalog.default.tbl1")
_ = spark.sql("DROP TABLE tbl1")