Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

SQL to Hive Cheat Sheet

502,039 views

Published on

If you’re already a SQL user then working with Hadoop may be a little easier than you think, thanks to Apache Hive. It provides a mechanism to project structure onto the data in Hadoop and to query that data using a SQL-like language called HiveQL (HQL).

This cheat sheet covers:
-- Query
-- Metadata
-- SQL Compatibility
-- Command Line
-- Hive Shell

Published in: Technology
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ♥♥♥ http://bit.ly/2F90ZZC ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating for everyone is here: ❤❤❤ http://bit.ly/2F90ZZC ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating for everyone is here: ❶❶❶ http://bit.ly/2Y8gKsI ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ♥♥♥ http://bit.ly/2Y8gKsI ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

SQL to Hive Cheat Sheet

  1. 1. Twitter: twitter.com/hortonworksCall: 855-HADOOP-HELP Web:qubole.com/try We Do Hadoop           Contents Cheat Sheet Hive for SQL Users   1 Additional Resources 2 Query, Metadata 3 Current SQL Compatibility, Command Line, Hive Shell         If you’re already a SQL user then working with Hadoop may be a little easier than you think, thanks to Apache Hive. Apache Hive is data warehouse infrastructure built on top of Apache™ Hadoop® for providing data summarization, ad hoc query, and analysis of large datasets. It provides a mechanism to project structure onto the data in Hadoop and to query that data using a SQL-like language called HiveQL (HQL).       Use this handy cheat sheet (based on this original MySQL cheat sheet) to get going with Hive and Hadoop.     Additional Resources   Learn to become fluent in Apache Hive with the Hive Language Manual: https://cwiki.apache.org/confluence/display/Hive/LanguageManual       Get in the Hortonworks Sandbox and try out Hadoop with interactive tutorials: http://hortonworks.com/sandbox       Try out Qubole Data Service (QDS) for free: http://www.qubole.com/try    
  2. 2. Twitter: twitter.com/hortonworksCall: 855-HADOOP-HELP Web:qubole.com/try We Do Hadoop     Query Function MySQL HiveQL Retrieving information SELECT  from_columns  FROM  table  WHERE  conditions;   SELECT  from_columns  FROM  table  WHERE  conditions;   All values SELECT  *  FROM  table;   SELECT  *  FROM  table;   Some values SELECT  *  FROM  table  WHERE  rec_name  =  “value”;   SELECT  *  FROM  table  WHERE  rec_name  =  "value";     Multiple criteria SELECT  *  FROM  table  WHERE  rec1=”value1”  AND   rec2=”value2”;   SELECT  *  FROM  TABLE  WHERE  rec1  =  "value1"  AND   rec2  =  "value2";     Selecting specific columns SELECT  column_name  FROM  table;   SELECT  column_name  FROM  table;     Retrieving unique output records SELECT  DISTINCT  column_name  FROM  table;   SELECT  DISTINCT  column_name  FROM  table;     Sorting SELECT  col1,  col2  FROM  table  ORDER  BY  col2;   SELECT  col1,  col2  FROM  table  ORDER  BY  col2;     Sorting backward SELECT  col1,  col2  FROM  table  ORDER  BY  col2  DESC;   SELECT  col1,  col2  FROM  table  ORDER  BY  col2  DESC;     Counting rows SELECT  COUNT(*)  FROM  table;   SELECT  COUNT(*)  FROM  table;     Grouping with counting SELECT  owner,  COUNT(*)  FROM  table  GROUP  BY   owner;   SELECT  owner,  COUNT(*)  FROM  table  GROUP  BY   owner;     Maximum value SELECT  MAX(col_name)  AS  label  FROM  table;   SELECT  MAX(col_name)  AS  label  FROM  table;     Selecting from multiple tables (Join same table using alias w/”AS”) SELECT  pet.name,  comment  FROM  pet,  event  WHERE   pet.name  =  event.name;   SELECT  pet.name,  comment  FROM  pet  JOIN  event  ON   (pet.name  =  event.name);         Metadata   Function MySQL HiveQL Selecting a database USE  database;   USE  database; Listing databases SHOW  DATABASES;   SHOW  DATABASES; Listing tables in a database SHOW  TABLES;   SHOW  TABLES;   Describing the format of a table DESCRIBE  table;   DESCRIBE  (FORMATTED|EXTENDED)  table;   Creating a database CREATE  DATABASE  db_name;   CREATE  DATABASE  db_name;   Dropping a database DROP  DATABASE  db_name;   DROP  DATABASE  db_name  (CASCADE);      
  3. 3. Twitter: twitter.com/hortonworksCall: 855-HADOOP-HELP Web:qubole.com/try We Do Hadoop       Color Key Hive  0.10   Hive  0.11   FUTURE     Current SQL Compatibility       Command Line Function Hive Run query hive  -­‐e  'select  a.col  from  tab1  a'   Run query silent mode hive  -­‐S  -­‐e  'select  a.col  from  tab1  a'   Set hive config variables hive  -­‐e  'select  a.col  from  tab1  a'  -­‐hiveconf  hive.root.logger=DEBUG,console   Use initialization script hive  -­‐i  initialize.sql   Run non-interactive script hive  -­‐f  script.sql       Hive Shell Function Hive Run script inside shell source  file_name   Run ls (dfs) commands dfs  –ls  /user   Run ls (bash command) from shell !ls   Set configuration variables set  mapred.reduce.tasks=32   TAB auto completion set  hive.<TAB>   Show all variables starting with hive set   Revert all variables reset   Add jar to distributed cache add  jar  jar_path   Show all jars in distributed cache list  jars   Delete jar from distributed cache delete  jar  jar_name     Hive SQL Datatypes Hive SQL Semantics INT   SELECT,  LOAD  INSERT  from  query   TINYINT/SMALLINT/BIGINT   Expressions  in  WHERE  and  HAVING   BOOLEAN   GROUP  BY,    ORDER  BY,  SORT  BY   FLOAT   Sub-­‐queries  in  FROM  clause   DOUBLE   GROUP  BY,  ORDER  BY   STRING   CLUSTER  BY,  DISTRIBUTE  BY   TIMESTAMP   ROLLUP  and  CUBE   BINARY   UNION   ARRAY,  MAP,  STRUCT,  UNION   LEFT,  RIGHT  and  FULL  INNER/OUTER  JOIN   DECIMAL   CROSS  JOIN,  LEFT  SEMI  JOIN   CHAR   Windowing  functions  (OVER,  RANK,  etc)   VARCHAR   INTERSECT,  EXCEPT,  UNION,  DISTINCT     DATE   Sub-­‐queries  in  WHERE  (IN,  NOT  IN,  EXISTS/   NOT  EXISTS)     Sub-­‐queries  in  HAVING  

×