Dear Experts,
I am looking for a help in re-writing the below query which is already working in PySpark. However when I am running same query in Via Input tool sql editor its giving an error "Error Opening<code> No Columns Returns). I am using hortonworks driver to connect to Hive files and querying hive files to pull data through beloe sql code. I know how to do it in Alteryx without using this code and via using Alteryx tools. But I don't want to unnecessary create a big workflow. It should be optimized.
ss.sql("use database")
v1 = ss.sql(''' Select FLOOR(B.C1/1000) AS NewColumn,
CASE WHEN A.C2 >= 5555 THEN A.C2 - 5555
WHEN A.C2 < 4545 THEN A.C2 - 2222
C.C3
From table1 AS A
Inner Join table2 AS B
ON A.Key = B.Key
LEFT JOIN table3 AS C
ON A.Key = C.Key
AND TRIM(C.xyz) = '9999-12-31'
AND trim(C.abc) = '2'
Where trim(A.LLM) = 'L"
AND trim(A.REC) = '9999-12-31'
AND trim(C.REC) = '9999-12-31'
AND trim(C.abc) = '2'
''')
Kindly help me to solve the error in Alteryx and re-write the query so that it should be work in Alteryx sql editor.
Thanks in Advance
@Kurohits your CASE statement has no final END statement, might be a reason for the error
@binuacs Ohh Sorry, it was my mistake. While sharing the query here, I forgot to add the END statement. Here is the query which is not working,
ss.sql("use database")
v1 = ss.sql(''' Select FLOOR(B.C1/1000) AS NewColumn,
CASE WHEN A.C2 >= 5555 THEN A.C2 - 5555
WHEN A.C2 < 4545 THEN A.C2 - 2222
END AS NIQ,
C.C3
From table1 AS A
Inner Join table2 AS B
ON A.Key = B.Key
LEFT JOIN table3 AS C
ON A.Key = C.Key
AND TRIM(C.xyz) = '9999-12-31'
AND trim(C.abc) = '2'
Where trim(A.LLM) = 'L"
AND trim(A.REC) = '9999-12-31'
AND trim(C.REC) = '9999-12-31'
AND trim(C.abc) = '2'
''')
@Kurohits can you check the part of your query is working
SELECT
A.Key,
FLOOR(B.C1 / 1000) AS NewColumn,
A.C2
FROM
table1 AS A
INNER JOIN
table2 AS B ON A.Key = B.Key