I am using hortonworks sandbox in Azure with spark 1.6. I have a Hive database populated with TPC-DS sample data. I want to read some SQL queries from external files and run them on the hive dataset in spark. I follow this topic Using hive database in spark which is just using a table in my dataset and also it writes SQL query in spark again, but I need to define whole, dataset as my source to query on that, I think i should use dataframes but i am not sure and do not know how! also I want to import the SQL query from external .sql file and do not write down the query again! would you please guide me how can I do this? thank you very much, bests!
how to use a whole hive database in spark and read sql queries from external files?
5.9k views Asked by Fardin Behboudi At
1
There are 1 answers
Related Questions in APACHE-SPARK
- Getting error while running spark-shell on my system; pyspark is running fine
- ingesting high volume small size files in azure databricks
- Spark load all partions at once
- Databricks Delta table / Compute job
- Autocomplete not working for apache spark in java vscode
- How to overwrite a single partition in Snowflake when using Spark connector
- Parse multiple record type fixedlength file with beanio gives oom and timeout error for 10GB data file
- includeExistingFiles: false does not work in Databricks Autoloader
- Spark connectors from Azure Databricks to Snowflake using AzureAD login
- SparkException: Task failed while writing rows, caused by Futures timed out
- Configuring Apache Spark's MemoryStream to simulate Kafka stream
- Databricks can't find a csv file inside a wheel I installed when running from a Databricks Notebook
- Add unique id to rows in batches in Pyspark dataframe
- Does Spark Dynamic Allocation depend on external shuffle service to work well?
- Does Spark structured streaming support chained flatMapGroupsWithState by different key?
Related Questions in HIVE
- Type Adapter for Offset in hive flutter
- HIVE Sql Date conversion
- How to set spark.executor.extraClassPath & spark.driver.extraClassPath in hive query without adding those in hive-site.xml
- Hive query on HUE shows different timestamp than programatically/on data
- descending order of data in hive using collect_set
- How to optimize writing to a large table in Hive/HDFS using Spark
- Spark SQL repartition before insert operation
- Alter datatype of complex type(array<struct>>) in hive
- SqlAlchemy connection to Hive using http thrift transport and basic auth
- Aggregate values into a new column while retaining the old column
- Is it possible to query MAPR hdfs/hive tables from Trino?
- Can we make a column having both partitioning and bucketing in hive?
- converting varchar(7) to decimal (7,5) in hive
- Extract all characters before numeric values in hive SQL
- Livy session to submit pyspark from HDFS
Related Questions in APACHE-SPARK-SQL
- Spark load all partions at once
- Joining 2 pyspark dataframes and continuing a running window sum and max
- Understanding least common type in databricks
- Insert selective columns into pyspark dataframe
- Dataframe won't save as anything - table, global temp view or temp view
- Spark TBLPROPERTIES to sql query?
- How to groupBy on two columns and work out avg total value for each grouped column using pyspark
- Spark SQL repartition before insert operation
- Convert 3 letter month column into a month number in Databricks SQL
- Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 1 - When reading table in SQL
- How to sort a PySpark dataframe rows by the order of a list?
- How to read csv files in dbfs using Spark SQL only?
- Handle different date formats in Pyspark
- Insert Overwrite partition data using Spark SQL on MINIO table
- update value in specific row by checking condition for another column values in pyspark
Related Questions in HADOOP2
- trino : io.trino.spi.trinoexception error reading from hdfs at position caused by java.io.ioexception 4 missing blocks , the stripe is : AlignedStripe
- how can i use job.addCacheArchive to load cache file from the output of another mapreduce?
- Configure hadoop.service.shutdown.timeout property
- Accumulo error: "ZOOKEEPER_HOME is not set or is not a directory" with separate ZooKeeper cluster
- Test cases fail with permission denied error with hadoop-minicluster initialization for 3.2.2 version
- calculating resources for the jobs in accepted state
- Module/Package resolution in Python
- How can I get job configuration in command line?
- How to get specific key/value from HDFS via HTTP or JAVA API?
- "ENOENT: No such file or directory" in hadoop while executing WordCount program
- What is the difference between FileInputStream/FileOutputStream Vs FSDataInputStream/FSDataOutputStream and where we will use them
- Spark 3.2.1 fetch HBase data not working with NewAPIHadoopRDD
- Nifi service going down every day
- invalid variable name error on hadoop-functions.sh file on manjaro
- I successfully Copied Data From a Source Table to a Partitioned Table Using Hive but The Data Can't be found In The Partitioned Table
Related Questions in TPC
- Gap between the job duration and stage duration in Spark
- Databricks SQL: Type Inference Challenges Using `COPY INTO`
- Error loading to MySQL TPC-H data via dbgen
- Does Spark TPCDS supports on YARN?
- Many "multiple definition of" errors shows up when compiling TPC-DS tools
- Can anyone help tranlating this sql queries to functional sql queries for sql server?
- How to Get Nested Structure Using EF Core 7 TPC
- .NET MAUI TCP listener; Scrollview not updating
- HammerDB: what does 'Number of Warehouses' mean?
- how to speed up TPC-H benchmark on Oracle database
- TPC-DS data in Snowflake Cloud warehouse is available only with 10 TB and 100 TB, is it possible to get it with fewer records(10 GB or even lesser)?
- PySpark using both aggregate and group by
- MySQL 1114 Error, Table /tmp/#sql is full
- TPC-H queries. Testing and how to run them?
- TPC-DS Query 6: Why do we need 'where j.i_category = i.i_category' condition?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Spark Can read data directly from Hive table. You can create, drop Hive table using Spark and even you can do all Hive hql related operations through the Spark. For this you need to use Spark
HiveContextFrom the Spark documentation:
Spark HiveContext, provides a superset of the functionality provided by the basic SQLContext. Additional features include the ability to write queries using the more complete HiveQL parser, access to Hive UDFs, and the ability to read data from Hive tables. To use a HiveContext, you do not need to have an existing Hive setup.
For more information you can visit Spark Documentation
To Avoid writing sql in code, you can use property file where you can put all your Hive query and then you can use the key in you code.
Please see below the implementation of Spark HiveContext and use of property file in Spark Scala.
Entry in Properties File :
Spark submit Command to run this job:
Note: Property File location should be HDFS location.