지정된 데이터 원본 경로를 포함하는 모든 DataFrame에 대해 캐시된 모든 데이터(및 연결된 메타데이터)를 무효화하고 새로 고칩니다.
문법
refreshByPath(path: str)
매개 변수
| 매개 변수 | 유형 | 설명 |
|---|---|---|
path |
str | 캐시를 새로 고칠 경로입니다. |
예제
# 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")