<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anupamaprashar on Medium]]></title>
        <description><![CDATA[Stories by Anupamaprashar on Medium]]></description>
        <link>https://medium.com/@anupamaprashar1925?source=rss-59a70740a71c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Anupamaprashar on Medium</title>
            <link>https://medium.com/@anupamaprashar1925?source=rss-59a70740a71c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 15:14:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anupamaprashar1925/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Managed Table and External table in Spark]]></title>
            <link>https://medium.com/@anupamaprashar1925/managed-table-and-external-table-in-spark-00430407763a?source=rss-59a70740a71c------2</link>
            <guid isPermaLink="false">https://medium.com/p/00430407763a</guid>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Anupamaprashar]]></dc:creator>
            <pubDate>Wed, 15 Nov 2023 07:28:45 GMT</pubDate>
            <atom:updated>2023-11-15T07:28:45.015Z</atom:updated>
            <content:encoded><![CDATA[<p>Dear Readers, I have tried simplifying the concept in layman&#39;s terms. I hope you enjoy it. Let’s get started.</p><p>A table in Spark can be created in many ways, it can be a temporary table whose database if not defined is the default, another is a managed table, and an external table.</p><p><strong>Temporary table:-</strong></p><p>It is created on top of dataFrames, it’s stored in the default database. Let’s say we have a groceries.csv file present. We need to read this file in a dataFrame and then using “createOrReplaceTempView” we create a table. A sample of temporary table creation is below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*r32iwuGhAnbgh4wJNAp_TA.png" /></figure><p><strong>Managed Tables:-</strong></p><p>We create the structure of the table and insert the data into the table, if we drop the table the structure as well as the data both get dropped.</p><p>The process to create a managed table is listed below:</p><ol><li>First we need to create a database.</li><li>Create a table in that database.</li><li>Insert data from the temporary table into this managed table.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y4gRA3SpRI7MqljesJAbPA.png" /><figcaption>Managed table query</figcaption></figure><p><strong>External Table:-</strong></p><p>If dropped, we lose metadata but nothing happens to data. we have data present in the dataLake.</p><p>The process to create an external table is listed below:</p><ol><li>First we need to create a database.</li><li>Create a table in that database and load the data using the path of the file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yt2b0CCNfOkdxq8kfK4sug.png" /><figcaption>External table query</figcaption></figure><p>How to know whether it is managed table or external table?</p><p>We can use <strong>spark.sql(“describe extended &lt;tablename&gt;”).show(truncate= False)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*wz93VBFzyVlsPzOrLR-Dvg.png" /></figure><p><strong>Difference between Managed table and External table:-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*ukh2lQWJsSQtfTNUg21jRw.png" /></figure><p>Thanks for reading. I hope to see you all soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00430407763a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>