Query regarding Temporary table's metadata in HIVE

0 votes

Hi,

Suppose I have created a temporary table in HIVE and used that table for further processing. If i create a temporary table where does the schema (or) Metadata gets stored, does it created in an External RDBMS table or in HDFS? 

If in HDFS where does that reside?

May 22 in Big Data Hadoop by Raj
41 views

1 answer to this question.

0 votes

Registered tables are not cached in memory.  The registerTempTable createOrReplaceTempView method will just create or replace a view of the given DataFrame with a given query plan. It will convert the query plan to canonicalized SQL string, and store it as view text in metastore, if we need to create a permanent view. 

You'll need to cache your DataFrame explicitly. e.g :

df.createOrReplaceTempView("my_table") # df.registerTempTable("my_table") for spark <2.+

spark.cacheTable("my_table")

Let's illustrate this with an example :

Using cacheTable :

scala> val df = Seq(("1",2),("b",3)).toDF

// df: org.apache.spark.sql.DataFrame = [_1: string, _2: int]

scala> sc.getPersistentRDDs

// res0: scala.collection.Map[Int,org.apache.spark.rdd.RDD[_]] = Map()


scala> df.createOrReplaceTempView("my_table")


scala> sc.getPersistentRDDs

// res2: scala.collection.Map[Int,org.apache.spark.rdd.RDD[_]] = Map()

scala> spark.cacheTable("my_table")

scala> sc.getPersistentRDDs

// res4: scala.collection.Map[Int,org.apache.spark.rdd.RDD[_]] = Map(2 -> In-memory table my_table MapPartitionsRDD[2] at cacheTable at <console>:26)

Now the same example using cache.registerTempTable cache.createOrReplaceTempView :

scala> sc.getPersistentRDDs

// res2: scala.collection.Map[Int,org.apache.spark.rdd.RDD[_]] = Map()


scala> val df = Seq(("1",2),("b",3)).toDF

// df: org.apache.spark.sql.DataFrame = [_1: string, _2: int]


scala> df.createOrReplaceTempView("my_table")


scala> sc.getPersistentRDDs

// res4: scala.collection.Map[Int,org.apache.spark.rdd.RDD[_]] = Map()


scala> df.cache.registerTempTable("my_table")


scala> sc.getPersistentRDDs

// res6: scala.collection.Map[Int,org.apache.spark.rdd.RDD[_]] =

// Map(2 -> ConvertToUnsafe

// +- LocalTableScan [_1#0,_2#1], [[1,2],[b,3]]

// MapPartitionsRDD[2] at cache at <console>:28)
answered May 22 by Tina

Related Questions In Big Data Hadoop

0 votes
1 answer

Query regarding String and Varchar in Hive

Varchar datatype is also saved internally as ...READ MORE

answered Feb 19 in Big Data Hadoop by Omkar
• 67,660 points
199 views
0 votes
1 answer

How Impala is fast compared to Hive in terms of query response?

Impala provides faster response as it uses MPP(massively ...READ MORE

answered Mar 21, 2018 in Big Data Hadoop by nitinrawat895
• 10,730 points
353 views
–1 vote
1 answer

How we can run spark SQL over hive tables in our cluster?

Open spark-shell. scala> import org.apache.spark.sql.hive._ scala> val hc = ...READ MORE

answered Dec 26, 2018 in Big Data Hadoop by Omkar
• 67,660 points
75 views
–1 vote
1 answer

Beeline and Hive Query Editor in Embedded mode

Running Hive client tools with embedded servers ...READ MORE

answered Dec 31, 2018 in Big Data Hadoop by Omkar
• 67,660 points
271 views
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,730 points
3,363 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,730 points
402 views
0 votes
10 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
16,674 views
0 votes
1 answer

Hadoop dfs -ls command?

In your case there is no difference ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by kurt_cobain
• 9,260 points
1,217 views
0 votes
1 answer
0 votes
1 answer

How to load unencrypted tables to encrypted in Hive?

Refer to the below command to load ...READ MORE

answered May 30 in Big Data Hadoop by John
31 views