Skip to end of metadataGo to start of metadata
The following query returns the first 5 customers to be created
![C# regular expressions cheat sheet C# regular expressions cheat sheet](/uploads/1/3/7/8/137828849/274381673.jpg)
- Perl Regular Expression Cheat Sheet
- Hive Regular Expression Cheat Sheet 2017
- Hive Regular Expression Cheat Sheet
GROUP BY; SORT/ORDER/CLUSTER/DISTRIBUTE BY; JOIN (Hive Joins, Join Optimization, Outer Join Behavior); UNION; TABLESAMPLE; Subqueries; Virtual Columns; Operators and UDFs; LATERAL VIEW; Windowing, OVER, and Analytics; Common Table Expressions
Select Syntax
TRUE if expression A is not equivalent to expression B otherwise FALSE. A expression A is less than expression B otherwise FALSE. A expression A is less than or equal to expression B otherwise FALSE. A B: all primitive types: TRUE if expression A is greater than expression B. The tables below are a reference to basic regex. While reading the rest of the site, when in doubt, you can always come back and look here. (It you want a bookmark, here's a direct link to the regex reference tables).I encourage you to print the tables so you have a cheat sheet on your desk for quick reference.
- CHEAT SHEET Hive Basics It is a data warehouse infrastructure based on Hadoop framework which is perfectly suitable for data summarization, analysis and querying. It uses an SQL like language called HQL (Hive query Language) HQL: It is a query language used to write the custom map reduce framework in Hive to perform more sophisticated analysis.
- Regular expression in hive. Ask Question Asked 3 years, 7 months ago. Active 3 years, 7 months ago. Viewed 28k times 3. I am learning simple regular expressions in.
- CHEAT SHEET Hive Basics It is a data warehouse infrastructure based on Hadoop framework which is perfectly suitable for data summarization, analysis and querying. It uses an SQL like language called HQL (Hive query Language) HQL: It is a query language used to write the custom map reduce framework in Hive to perform more sophisticated analysis.
- A SELECT statement can be part of a union query or a subquery of another query.
table_reference
indicates the input to the query. It can be a regular table, a view, a join construct or a subquery.- Table names and column names are case insensitive.
- In Hive 0.12 and earlier, only alphanumeric and underscore characters are allowed in table and column names.
- In Hive 0.13 and later, column names can contain any Unicode character (see HIVE-6013). Any column name that is specified within backticks (
`
) is treated literally. Within a backtick string, use double backticks (``
) to represent a backtick character. - To revert to pre-0.13.0 behavior and restrict column names to alphanumeric and underscore characters, set the configuration property
hive.support.quoted.identifiers
tonone
. In this configuration, backticked names are interpreted as regular expressions. For details, see Supporting Quoted Identifiers in Column Names (attached to HIVE-6013). Also see REGEX Column Specification below.
- Simple query. For example, the following query retrieves all columns and all rows from table t1.NoteAs of Hive 0.13.0, FROM is optional (for example,
SELECT 1+1
). - To get the current database (as of Hive 0.13.0), use the current_database() function:
- To specify a database, either qualify the table names with database names ('
db_name.table_name
' starting in Hive 0.7) or issue the USE statement before the query statement (starting in Hive 0.6).Fashion designer sketch pad. 'db_name.table_name
' allows a query to access tables in different databases.USE sets the database for all subsequent HiveQL statements. Reissue it with the keyword 'default
' to reset to the default database.
WHERE Clause
The WHERE condition is a boolean expression. For example, the following query returns only those sales records which have an amount greater than 10 from the US region. Hive supports a number of operators and UDFs in the WHERE clause:
As of Hive 0.13 some types of subqueries are supported in the WHERE clause.
ALL and DISTINCT Clauses
The ALL and DISTINCT options specify whether duplicate rows should be returned. If none of these options are given, the default is ALL (all matching rows are returned). DISTINCT specifies removal of duplicate rows from the result set. Note, Hive supports SELECT DISTINCT * starting in release 1.1.0 (HIVE-9194).
ALL and DISTINCT can also be used in a UNION clause – see Union Syntax for more information.
Partition Based Queries
In general, a SELECT query scans the entire table (other than for sampling). If a table created using the PARTITIONED BY clause, a query can do partition pruning and scan only a fraction of the table relevant to the partitions specified by the query. Hive currently does partition pruning if the partition predicates are specified in the WHERE clause or the ON clause in a JOIN. For example, if table page_views is partitioned on column date, the following query retrieves rows for just days between 2008-03-01 and 2008-03-31.
If a table page_views is joined with another table dim_users, you can specify a range of partitions in the ON clause as follows:
- See also Partition Filter Syntax.
- See also Group By.
- See also Sort By / Cluster By / Distribute By / Order By.
HAVING Clause
Hive added support for the HAVING clause in version 0.7.0. In older versions of Hive it is possible to achieve the same effect by using a subquery, e.g:
can also be expressed as
LIMIT Clause
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement.
LIMIT takes one or two numeric arguments, which must both be non-negative integer constants.
The first argument specifies the offset of the first row to return (as of Hive 2.0.0) and the second specifies the maximum number of rows to return.
When a single argument is given, it stands for the maximum number of rows and the offset defaults to 0.
The following query returns 5 arbitrary customers
The following query returns the first 5 customers to be created
The following query returns the 3rd to the 7th customers to be created
Perl Regular Expression Cheat Sheet
REGEX Column Specification
A SELECT statement can take regex-based column specification in Hive releases prior to 0.13.0, or in 0.13.0 and later releases if the configuration property
hive.support.quoted.identifiers
is set to none
. - We use Java regex syntax. Try http://www.fileformat.info/tool/regex.htm for testing purposes.
- The following query selects all columns except ds and hr.
More Select Syntax
See the following documents for additional syntax and features of SELECT statements:
- JOIN
There are four types of operators in Hive:
- Relational Operators
- Arithmetic Operators
- Logical Operators
- Complex Operators
Relational Operators
These operators are used to compare two operands. The following table describes the relational operators available in Hive:
Operator | Operand | Description |
---|---|---|
A = B | all primitive types | TRUE if expression A is equivalent to expression B otherwise FALSE. |
A != B | all primitive types | TRUE if expression A is not equivalent to expression B otherwise FALSE. |
A < B | all primitive types | TRUE if expression A is less than expression B otherwise FALSE. |
A <= B | all primitive types | TRUE if expression A is less than or equal to expression B otherwise FALSE. |
A > B | all primitive types | TRUE if expression A is greater than expression B otherwise FALSE. |
A >= B | all primitive types | TRUE if expression A is greater than or equal to expression B otherwise FALSE. |
A IS NULL | all types | TRUE if expression A evaluates to NULL otherwise FALSE. |
A IS NOT NULL | all types | FALSE if expression A evaluates to NULL otherwise TRUE. |
A LIKE B | Strings | TRUE if string pattern A matches to B otherwise FALSE. |
A RLIKE B | Strings | NULL if A or B is NULL, TRUE if any substring of A matches the Java regular expression B , otherwise FALSE. |
A REGEXP B | Strings | Same as RLIKE. |
Example
Let us assume the employee table is composed of fields named Id, Name, Salary, Designation, and Dept as shown below. Generate a query to retrieve the employee details whose Id is 1205.
The following query is executed to retrieve the employee details using the above table:
On successful execution of query, you get to see the following response:
The following query is executed to retrieve the employee details whose salary is more than or equal to Rs 40000.
On successful execution of query, you get to see the following response:
Arithmetic Operators
These operators support various common arithmetic operations on the operands. All of them return number types. The following table describes the arithmetic operators available in Hive:
Operators | Operand | Description |
---|---|---|
A + B | all number types | Gives the result of adding A and B. |
A – B | all number types | Gives the result of subtracting B from A. |
A * B | all number types | Gives the result of multiplying A and B. |
A / B | all number types | Gives the result of dividing B from A. |
A % B | all number types | Gives the reminder resulting from dividing A by B. |
A & B | all number types | Gives the result of bitwise AND of A and B. |
A | B | all number types | Gives the result of bitwise OR of A and B. |
A ^ B | all number types | Gives the result of bitwise XOR of A and B. |
~A | all number types | Gives the result of bitwise NOT of A. |
Example
![C# regular expressions cheat sheet C# regular expressions cheat sheet](/uploads/1/3/7/8/137828849/274381673.jpg)
The following query adds two numbers, 20 and 30. G10 remote pairing.
On successful execution of the query, you get to see the following response:
Logical Operators
The operators are logical expressions. All of them return either TRUE or FALSE.
Operators | Operands | Description |
---|---|---|
A AND B | boolean | TRUE if both A and B are TRUE, otherwise FALSE. |
A && B | boolean | Same as A AND B. |
A OR B | boolean | TRUE if either A or B or both are TRUE, otherwise FALSE. |
A || B | boolean | Same as A OR B. |
NOT A | boolean | TRUE if A is FALSE, otherwise FALSE. |
!A | boolean | Same as NOT A. |
Example
The following query is used to retrieve employee details whose Department is TP and Salary is more than Rs 40000.
On successful execution of the query, you get to see the following response:
Hive Regular Expression Cheat Sheet 2017
Complex Operators
These operators provide an expression to access the elements of Complex Types. Uml syntax cheatsheet.
Hive Regular Expression Cheat Sheet
Operator | Operand | Description |
---|---|---|
A[n] | A is an Array and n is an int | It returns the nth element in the array A. The first element has index 0. |
M[key] | M is a Map<K, V> and key has type K | It returns the value corresponding to the key in the map. |
S.x | S is a struct | It returns the x field of S. |