Impala - AnalysisException: Subqueries are not supported in the select list - impala

This query that I am doing in impala does not work for me, how else could I do it? In Hive if I was allowed in this style but in Impala it is not allowed.
enter image description here

Related

Hue: Search for all tables containing a certain field

I am trying to identify all the tables that contain a certain column (for example, “thenameoffield”) using Hue
In the Hue User Guide under Data Catalogs, it suggests entering type:field name in the search bar, but when I do this there are no results found. There are no clear examples in the documentation, but I assume "name" is the name of the field I want to search for. The documentation does not state if wildcard can be used, such as "name". I did try this but no results were produced.
I also tried running SQL queries, but based on the error messages, Hue does not accept the syntax (assuming it's correct to start with):
I. Entering the syntax above into the Hue query area:
type:field(column): ‘thenameoffield’ AND
type:field 'thenameoffield'
with and without quotes, but it doesn’t work. “AnalysisException: Syntax error in line2:undefined: type:field(column): /thenameoffield’”
II. I also tried:
SELECT * FROM INFORMATION_SCHEMA.COLUMNS;
but not working either- “AnalysisException: Syntax error in line2:undefined: EXPLAIN SELECT * FROM,…Exception: Syntax error”
III. I also attempted to use:
SELECT
sys.columns.name AS ColumnName,
tables.name AS TableName
FROM
sys.columns
JOIN sys.tables ON
sys.columns.object_id = tables.object_id
WHERE
sys.columns.name LIKE ‘%thenameoffield%’
but received the error message: AnalysisException: Syntax error in line 1: undefined: SELECT sys.columns.name as ColumnName,…
Any help would be greatly appreciated.
The Catalog search is currently powered by either Apache Atlas or Cloudera Navigator so you would need to point Hue to those to make it work.
About the DB metadata querying, you might have more chance by tagging the question with Apache Hive instead of Hue (as Hue just sends the query to Hive). Would also help to have the Hive verion.

Hive SQL Select is not working with multiple AND criteria, showing error: The operator 'AND' accepts at least 2 argument

I am trying to run a very simple query that just select all the rows based upon some multiple criteria and all are inclusive i.e. I am using AND in select HiveQL statement. The table is an external table in Hive and the storage handler is phoenix, so I checked in phoenix also about that query and it is working fine, but in Hive, it is showing some java IO exception error which I am not able to get where I am wrong. The query I am using is:
SELECT * FROM msme_api.msme_jk WHERE gender='Male' AND socialcategory='General';
The complete error message is:
Error: java.io.IOException: org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException: The operator 'AND' accepts at least 2 argument. (state=,code=0)
I am trying for external and for internal Hive tables, In both, the issues are still the same but when I give order by, OR statement then it's surprising that it works.
SELECT * FROM msme_api.msme_jk WHERE gender='Male' AND socialcategory='General' order by aid;
SELECT * FROM msme_api.msme_jk WHERE gender='Male' OR socialcategory='General';
Both works fine but with AND, I am getting the error.
I still confused about how hive is taking and processing the above queries and why I am not able to execute simple select statement. Any help will be appreciated.

SKIP LOCKED DATA Syntax issue in DB2

I am trying to execute simple select query with SKIP LOCKED DATA
but getting syntax error. Below is the sample query
SELECT ELEMENT FROM WORKQUEUE
WHERE PRIORITY = '1' AND STATUS='OPEN'
SKIP LOCKED DATA;
Got error as below
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=SKIP;
<query_expression>;END-OF-STATEMENT, DRIVER=3.61.86
But as per documents it is valid query. Please let me know if I am doing something wrong?
I suspect you are not using Db2 for z/OS 10.0.0
I suspect you are using e.g Db2 11.1 and you need a manual page from that Db2 platform such as
"Evaluate uncommitted data through lock deferral" - https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.admin.perf.doc/doc/c0011218.html
because Db2 for Linux, Unix and Windows does not support the SKIP LOCKED DATA clause directly

Amazon redshift - extracting time from timestamp SQL error

I am trying to extract the time from a datetime column in my Amazon Redshift database (Postgresql 8.0). I have already referred to previous questions such as this. But I am getting an unusual error.
When I try:
SELECT collected_timestamp::time
or
SELECT cast(collected_timestamp as time)
I get the following error:
ERROR: Specified types or functions (one per INFO message) not supported on Redshift tables
The goal is to pull the time portion from the timestamp such that 2017-11-06 13:03:28 returns 13:03:28.
This seems like an easy problem to solve but for some reason I am missing something. Researching that error does not lead to anything meaningful. Any help is appreciated.
Note that Redshift <> PostgreSQL - it was forked from PostgreSQL but is very different under the hood.
You're trying to cast a timestamp value to a data type of "time" which does not exist in Redshift. To return a value that is only the time component of a timestamp you will need to cast it to a character data type, e.g.:
SELECT to_char(collected_timestamp, 'HH24:MI:SS');
There are a few ways, here is one i use:
SELECT ('2018-03-07 21:55:12'::timestamp - trunc('2018-03-07 21:55:12'::timestamp))::time;
I hope that helps.
EDIT: I have made incorrect use of ::time please see comments on other answer.

Hive: Select * command is not working similar to RDBMS

I installed apache hive-0.9.0 and start executing some basic commands and i found one abnormal behavior in select* command. In select statement after * any random characters are allowed in hive but in RDBMS its not allowed. I am not sure its expected behavior or bug in hive. Could some please confirm?
In the below query "abcdef" is random characters.
In RDBMS(oracle):
select *abcdef from mytable;
Output:
ERROR prepare() failed with: ORA-00923: FROM keyword not found where expected
In Hive:
select *abcdef from mytable;
Output:
Query worked fine and display all the records of mytable.
In RDBMS,select is followed by column name/* , but in HIVE,it may be column name/*/any regular expression(partitions) .
Go through this link
http://www.qubole.com/5-tips-for-efficient-hive-queries/
it provides whole description
I got response from apache hive committe. Its a indeed bug in hive. They filed a improvement ticket for this issue
Jira Ticket: https://issues.apache.org/jira/browse/HIVE-8155