<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Does CACHE TABLE/VIEW have a create or replace like view? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/does-cache-table-view-have-a-create-or-replace-like-view/m-p/19643#M13191</link>
    <description>&lt;P&gt;Hi @Matt Fury​&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes...I guess cache overwrites each time you run it because for me it took nearly same amount of time for 1million records to be cached. &lt;/P&gt;&lt;P&gt;However, you can check whether the table is cached or not using .storageLevel method. &lt;/P&gt;&lt;P&gt;E.g.  I have a table named table1. Before caching, if I run the below, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;spark.table("table1").storageLevel -- Output will be StorageLevel(False, False, False, False, 1)&lt;/P&gt;&lt;P&gt;cache table table1;  -- Now I'm caching the table&lt;/P&gt;&lt;P&gt;spark.table("table1").storageLevel -- Output will be StorageLevel(True, True, False, True, 1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can get individual flags using the respective storagelevel like &lt;/P&gt;&lt;P&gt;spark.table("table1").storageLevel.useMemory&lt;/P&gt;&lt;P&gt;spark.table("table1").storageLevel.useDisk&lt;/P&gt;&lt;P&gt;spark.table("table1").storageLevel.useOffHeap etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For more on storage levels, check out &lt;A href="https://sparkbyexamples.com/spark/spark-persistence-storage-levels/" target="test_blank"&gt;https://sparkbyexamples.com/spark/spark-persistence-storage-levels/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers..&lt;/P&gt;</description>
    <pubDate>Wed, 30 Nov 2022 17:53:15 GMT</pubDate>
    <dc:creator>UmaMahesh1</dc:creator>
    <dc:date>2022-11-30T17:53:15Z</dc:date>
    <item>
      <title>Does CACHE TABLE/VIEW have a create or replace like view?</title>
      <link>https://community.databricks.com/t5/data-engineering/does-cache-table-view-have-a-create-or-replace-like-view/m-p/19642#M13190</link>
      <description>&lt;P&gt;I'm trying to cache data/queries that we normally have as temporary views that get replaced when the code is run based on dynamic python. What I'd like to know is will CACHE TABLE get overwritten each time you run it? Is it smart enough to recognize the table is already cached and skip? Trying to avoid having this run every time if it exists.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 17:04:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/does-cache-table-view-have-a-create-or-replace-like-view/m-p/19642#M13190</guid>
      <dc:creator>fury88</dc:creator>
      <dc:date>2022-11-30T17:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Does CACHE TABLE/VIEW have a create or replace like view?</title>
      <link>https://community.databricks.com/t5/data-engineering/does-cache-table-view-have-a-create-or-replace-like-view/m-p/19643#M13191</link>
      <description>&lt;P&gt;Hi @Matt Fury​&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes...I guess cache overwrites each time you run it because for me it took nearly same amount of time for 1million records to be cached. &lt;/P&gt;&lt;P&gt;However, you can check whether the table is cached or not using .storageLevel method. &lt;/P&gt;&lt;P&gt;E.g.  I have a table named table1. Before caching, if I run the below, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;spark.table("table1").storageLevel -- Output will be StorageLevel(False, False, False, False, 1)&lt;/P&gt;&lt;P&gt;cache table table1;  -- Now I'm caching the table&lt;/P&gt;&lt;P&gt;spark.table("table1").storageLevel -- Output will be StorageLevel(True, True, False, True, 1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can get individual flags using the respective storagelevel like &lt;/P&gt;&lt;P&gt;spark.table("table1").storageLevel.useMemory&lt;/P&gt;&lt;P&gt;spark.table("table1").storageLevel.useDisk&lt;/P&gt;&lt;P&gt;spark.table("table1").storageLevel.useOffHeap etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For more on storage levels, check out &lt;A href="https://sparkbyexamples.com/spark/spark-persistence-storage-levels/" target="test_blank"&gt;https://sparkbyexamples.com/spark/spark-persistence-storage-levels/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers..&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 17:53:15 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/does-cache-table-view-have-a-create-or-replace-like-view/m-p/19643#M13191</guid>
      <dc:creator>UmaMahesh1</dc:creator>
      <dc:date>2022-11-30T17:53:15Z</dc:date>
    </item>
  </channel>
</rss>

