LATERAL VIEW and CASE Statement in KSQL - view

is there a LATERAL VIEW Statement in KSQL i cant finde anything in the docs. Or is there any alternative Comand to get the same result on column? When I use the Statement I get following error
line 1:64: mismatched input 'view' expecting ';'
Caused by: org.antlr.v4.runtime.InputMismatchException
Also as i see there is no CASE Statement, is there also some alternative for this?

These are not currently supported. You can upvote the relevant github issues to help us gauge relative demand for the features:
CASE
EXPLODE / LATERAL VIEW

Related

How to add comment in Clickhouse SQL query

I met this strange thing and want to understand how you handle it.
I am using Monaco editor to write sql query and then using node clickhouse library to run the query, so, in the editor, user entered this:
-- Explain
select * from table 1
and the query sent to clickhouse is this:
-- Explain\nselect * from table 1
But when running this, I got error
:"SyntaxError: Unexpected number in JSON at position 2\n at pa...
Seemed the comment here is causing the error.
Can you tell me how to put comment into the query and send to clickhouse to run?
Have you already found the solution to your problem?
Otherwise I can advise you to use the "multi-line comments" as follows:
/* Explain */
SELECT *
FROM table1
It gets around the problem to achieve the desired result.

expecting KW_EXCHANGE near 'table' in alter exchange partition

I am dealing with a table in hive which does not have partitions and with input format as textinputformat. This is not an external table and I create it using "Create table as select" template.
I use the alter table statement to rename the table as given below:
ALTER TABLE testdb.temptable RENAME TO testdb.newtable;
I get the following error:
Error: Error while compiling statement: FAILED: ParseException line 1:32 mismatched input 'RENAME' expecting KW_EXCHANGE near 'temptable' in alter exchange partition (state=42000,code=40000)
Closing: org.apache.hive.jdbc.HiveConnection
I see it is a bug in hive. I use the version:
Hive 0.12.0-cdh5.1.4
How do i go about fixing this issue. Thanks in advance for the help!
It's not exactly a bug, just a side effect of Open Source when it's done by a motley crew of people all around the world with no "product owner" and no incentives to use a common programming style (or run extensive regression tests, or <insert your complaint here>).
Aaaaaaah, now that it's said, I feel better... Let's get to the point.
In HiveQL the alter command does not use the same semantics as create or select; specifically, you cannot use the "ALTER DATABASE.TABLE" notation. If you try, then the HQL parser just fails with a queer error message, as you can see by yourself.
That's the way it is. You must type a use command first, then your alter command with just the table name. Yes, it sucks. But that's the way it is. And I see no reason why it should improve any time soon.
[Update Jun-2017] looks like ALTER finally supports the DB.TABLE syntax, on recent Cloudera distro (tested on CDH 5.10 with Hive 1.1.0 - but since they usually include a number of back-ports in their distro, maybe it's a feature of Hive 1.2+)
I have similar error message it is gone after using alternative syntax, selecting schema and reference table by the short name:
USE mydb;
ALTER TABLE mytable RECOVER PARTITIONS;

How to use select statements in control file in oracle

I want to add the following statement in control file(sql load file).
select
123456,
regexp_replace(123456, '(\d+)(\d{2})', '\1.\2')
from table_1;
Please advice.
The Oracle doc mentions the option of applying SQL operators to fields. I guess that might be what you're looking for. That would be:
...
your_number_field char,
your_regexp_processed_field char "regexp_replace(:your_number_field, '(\\d+)(\\d{2})', '\\1.\\2')",
...
Anyway, I rather suggest that, instead, you create a view over your table_1 that does this "calculation" for you.

Crystal reports not connectiing to Views from AS/400 IFS

I have a strange case here. I created a View in AS/400. I need to have view not join logical because I need to do a UNION ALL. The view is created and I went to IFS and granted permissions ALL. But when I open Crystal Reports, make the connection to iSeries, and go to that library of the View, it is not showing, so I cannot use.
Is there anything else I need to do?
I just tried something else. this is the view:
CREATE VIEW MKLIB/BEMPLOCM AS
((SELECT LMRIDC, LMCOM#, LMWHS#, LMLOC1, LMLOC2, LMLOC3, LMLTPC, LMLCT1
FROM
((SELECT LMRIDC, LMCOM#, LMWHS#, LMLOC1, LMLOC2, LMLOC3, LMLTPC, LMLCT1
FROM ASTDTA/ICLOCMLM WHERE LMLTPC IN ('PCK', 'PAL', 'RAK')) t1
EXCEPTION JOIN
(SELECT * FROM ASTDTA/ICBALMIE) t2
ON LMLOC1=IELOC1 AND LMLOC2=IELOC2 AND LMLOC3=IELOC3 )
EXCEPTION JOIN
(SELECT * FROM ASTDTA/ICBLDTIR) t3
ON LMLOC1=IRLOC1 AND LMLOC2=IRLOC2 AND LMLOC3=IRLOC3 ))
Now in Crystal reports there is also COMMAND to use to get your data, there you can make the same query but although I want it on the AS/400 for time consideration, the union is needed otherwise i have to run the queries via CL all day. SO I took the above code from the SELECT point, and got this error:
failed to retrieve data from the database. Details: HY000 IBM ISeries
ACCESS ODBC DRIVER (DB2 UDB) sql 5016 - Qualified object name ICLOCMLM
not valid. Vendor code 5016.
Not sure what that means.
Use the GRANT statement to control SQL privileges.
If the view is over regular files you may also have to use the commands GRTOBJAUT, EDTOBJAUT and RVKOBJAUT to modify authorization on those objects.
"It does not list it in the library when I see the tables and views in crystal."
Are you sure that the view is actually in the library you think?
What may have happened is that it may have been created in another library. Try checking in QGPL library, or if you have a library that matches your user profile name, check there.
If the question is 'Why do I get Qualified object name ICLOCMLM not valid.' the answer is probably that you are using *SQL naming and the statement you are running is using *SYSTEM naming. Try changing FROM ASTDTA/ICLOCMLM to FROM ASTDTA.ICLOCMLM and see if the 5016 error goes away.

Quering Oracle materialized view - column ambiguously defined

I have a trouble querying view in Oracle.
Here is the view (my_cool_view) definition:
SELECT *
FROM mview1 JOIN
mview2 USING(col_id)
where mview1 and mview2 is materialized views. I can't access to definition of this materialized views. I've tried this query:
select r.title from my_cool_view r;
and got ORA-00918: column ambiguously defined error. I got this error for subset of columns in my_cool_view.
If I run this query:
select * from my_cool_view;
all works fine.
You are asking about desc my_cool_view in comments, sorry I can't provide schema information because it's confidential. The only I can say it contains about 80 columns, and only one (col_id) don't cause above error.
Do you have any ideas what is the case and how to fix it?
Thanks in advance.
Sorry for misled you, the first version of question was too bad.
You probably have 2 columns called title from different tables/views that you've joined. If you select * then this will work as the duplicate title columns will get a different alias (like TITLE1). When you explicitly ask for one of the title columns the database needs to know which one you want and thus throws the error.
Just make sure that the title columns have a different alias:
select EMP.TITLE EMP_TITLE, DEPT.TITLE DEPT_TITLE
FROM ...

Resources