Hive list of reserved words - hive

Can anybody point me to a page listing all the reserved words in Hive?
There are many questions here aimed to using the reserved words as a column or table names after such columns or tables were created. My question is about how to avoid creating such columns or tables.
If you google "some_DBMS reserved words", the first hit is the official page.
I.e., here it's for Oracle, here for Postgres, here for MySQL, etc. But not for Hive.
Here is the only page I was able to find, but it's inaccurate - it does not include the DIV keyword, which is empirically found to be reserved.

I was looking into the code and found it to be in:
/src/java/org/apache/hadoop/hive/ql/parse/HiveLexerParent.g
https://github.com/apache/hive/blob/rel/release-3.1.0/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g

You can get reserve keyword of hive:
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL

Related

Reserved words of AgensGraph

I am trying to load 1,000,000 lines of data into AgensGraph.
It is simple data with fake user profiles, and I named the label as "user".
However, ERROR statement popped out, and I believe it is because the word "user"
is reserved as one of the reserved words of AgensGraph. When I changed the word to "person", it creates vertexes without any problem.
agraph=# LOAD FROM vlabel_user AS user CREATE (a:user=row_to_json(user)::jsonb);
ERROR: syntax error at or near "user"
LINE 1: LOAD FROM vlabel_user AS user CREATE (a:user=row_to_json(use...
agraph=# LOAD FROM vlabel_user AS person CREATE (a:person=row_to_json(person)::jsonb);
GRAPH WRITE (INSERT VERTEX 1000000)
After I found this out, I wonder whether there are other words besides "user" that I cannot use. I couldn't find any information through the Google, so I
am asking others' help.
Right, "user" is reserved word. agensgraph is based on postgresql and supports all SQL queries available in postgresql. For this reason, all reserved words in postgresql are also reserved words in agensgraph. (The reserved words for postgresql can be found here.)
If you want to use reserved words, enclose the identifier in double-quotes(e.g. : "user").
Additionaly, "MATCH" and "RETURN" are added to reserved keyword in AgensGraph for Cypher grammar.

How to query tables that have conflicting name?

i have a table called ORDER, when i try to query it using
select * from Order
i get the error 'invalid query'
how to do access this table please?
thank you
Step 1
Don't ever used reserved words for object (or column) names.
SQL 1992 Standard (search for <reserved word>)
SQL Server reserved words
MySQL reserved words
DB2 reserved words
Step 2
If you've inherited such a thing that you are not able to change, then you need to use "quoted identifiers".
I advocate
SELECT *
FROM "Order"
As it is a standard identifier, so will work better across platforms.
ORDER is a reserved word in SQL. Put double quotes around it:
select * from "Order"
And also, I personally think ORDERS is a better name. (Because several orders are stored in the table.)
Late edit: List of reserved words, in different versions of the SQL standard:
http://developer.mimer.com/standard/reservedwords/sql-reserved-words.tml
It's generally a good idea to not use reserved words for database object names (tables, views & etc.). Sometimes you just got to deal with it though. The below query should work for you.
select * from [Order]
Just put the brackets around the table name.
Hope this helps!

SQL: LIKE and Contains — Different results

I am using MS SQL Express SQL function Contains to select data. However when I selected data with LIKE operator, I realised that Contains function is missing a few rows.
Rebuilt indexes but it didn't help.
Sql: brs.SearchText like '%aprilis%' and CONTAINS(brs.SearchText, '*aprilis*')
The contains function missed rows like:
22-28.aprīlis
[1.aprīlis]
Sīraprīlis
PS. If I search directly CONTAINS(brs.SearchText, '*22-28.aprīlis*'), then it finds them
contains is functionality based on the full text index. It supports words, phrases, and prefixed matches on words, but not suffixed matches. So you can match words that start with 'aprilis' but not words that end with it or that contain it arbitrarily in the middle. You might be able to take advantage of a thesaurus for these terms.
This is explained in more detail in the documentation.

What does the output_expression for "DELETE FROM table" do?

I recently ran across an oddity. The following is valid SQL:
DELETE FROM customer *;
The documentation for PostgreSQL DELETE says the star is a possible value for the output_expression:
An expression to be computed and returned by the DELETE command after
each row is deleted. The expression can use any column names of the
table or table(s) listed in USING. Write * to return all columns.
I tried it with and without the star and can't see a difference. In fact, I can put just about anything single word after the table name and it is accepted. It doesn't even have to be an actual column name. Nothing extra is returned.
db=> DELETE FROM customer wheeeeeee;
DELETE 19
So what does it do and what could I use it for?
Question also posted on the PostgreSQL mailing list.
The asterisk is not output_expression, for this you would have to use the RETURNING keyword. It is instead an old, obsolete syntax for including child tables in queries. (The last version for which it is documented seems to be PostgreSQL 8.1. Since the syntax is still valid it is a documentation bug, as Tom Lane points out in the post linked below.)
Since PostgreSQL 7.1 this is the default (unless sql_inheritance is set to off) and the ONLY keyword is used for the opposite, so the * is not very useful.
See this explanatory post from Tom Lane on the PostgreSQL mailing list.

SQL 2008 full text word break pointers

If I do a full text search on SQL 2008, can I get a pointer ( File , or Database) so that I don't have to load the 100MB memo field to by Business Object and do search again ?
It does not appear that SQL Server 2008 supports the retrieval of offset pointers to the found keywords within the memo field.
Full text search does not search the memo fields, but searches an index that specifies which keywords are in which documents. The information about where these words appear within each document does not seem to be available in the full text search index.
Microsoft offers a type of query called sys.dm_fts_index_keywords_by_document. With it, you can enable the following use cases:
“I want to know how many keywords the full-text index contains”
“I want to know if a keyword is part of a given doc/row”
“I want to know how many times a keyword appears in the whole full-text index” (sum(occurrence_Count) where keyword=……)
“I want to know how many times a keyword appears in a given doc/row”
“I want to know how many keywords a given doc/row contains”
“I want to retrieve all the keywords belonging to a given doc/row”
However, scenarios not covered in this release:
“I want to know the offset (word or byte) of a given keyword in a given doc/row”
“I want to know the distance (in words) between two keywords per a given doc/row”
Sources:
http://technet.microsoft.com/en-us/library/cc721269.aspx#_Toc202506233
http://msdn.microsoft.com/en-us/library/cc280607.aspx