Collect list function in hive and impala - hive

I am using
concat_ws(' ', collect_list(field1)) as field1,
but the query is not running in impala.
Does impala not support this function?
If not, what is an alternative for a similar operation in impala?

You can use group_concat() function in impala,
Plase refer https://www.cloudera.com/documentation/enterprise/5-5-x/topics/impala_group_concat.html

Related

starts_with in presto?

I am new to writing sql queries in presto and was looking for a function similar to 'starts_with'.
If a string starts with a given substring then the query needs to return that record.
In Postgresql, I am currently doing select * from tableA where name~'^Joh'. Whats the equivalent of this in Presto?
PostgreSQL and presto are RDBMS based on SQL. It is weird to see that you've learned a PostgreSQL proprietary add on (regular expressions) to the language before learning the standard SQL functions. In SQL you use LIKE for pattern matches:
select * from tableA where name like 'Joh%';
You can use Like in SQL. You can go through this link https://www.w3schools.com/sql/sql_like.asp. Using like you can search for a specified pattern.
In presto you can use regexp_like() which runs little faster than other like operators.For your case try below query which should provide you with expected functionality.
select regexp_like('John', '^John')

Vertica's LISTAGG() Big Query Equivalent

While migrating Vertica run reports to BQ, I stumbled upon a Vertica pre-built function LISTAGG().
What is the equivalent on Big Query?
Replace with this
Vertica:
LISTAGG(column,'delimiter')
Big Query:
STRING_AGG(column,'delimiter')
Make sure to CAST(column as STRING) in case Vertica's column is from INT

Iterative functions for Apache Impala

am working on my graduation project and its using Impala ,
so i want to ask is there anyway so i can use options like ' for , if , while ' ... etc in Cloudera Impala ?
#Atef Ibrahim you can use if :
if(boolean condition, type ifTrue, type ifFalseOrNull)
for more info you can read the doc Impala Conditional Functions
Regarding the for/while loop statement you can read
Write a While loop in Impala SQL?

Hive Udf for TOP funtion

We are joining tables from hana and hive and a view creating query from Smart Data Access
EX: Select top 10 from hana.table join hive.table
Hana support TOP funtion but Hive doesnt. Is there any existing UDF present in Hive similar to TOP. I know in hive we have LIMIT but we required a UDF function which similar to hana?
Please suggest any workaround for this problem. Thanks in advance.
You will have to use the LIMIT function

REGEXP_CONTAINS not recognized

Happy new years, stackoverflow!
I am trying to use some regex functions in bigquery but some of them return error as if I have the name wrong.
SELECT REGEXP_CONTAINS(path, r'^abc$') FROM [tablename]
Query Failed
Error: 2.24 - 2.26: Unrecognized function regexp_contains
Where as if I do a similar regex function, the function text in the editor changes color and the query works.
SELECT REGEXP_EXTRACT(path, r'^abc$') FROM [tablename]
It should work since it's documented in this link.
Does anyone know how to fix this?
BigQuery Legacy SQL and Standard SQL support different set of regular expression functions
Legacy SQL Regular Expression Functions:
REGEXP_MATCH, REGEXP_EXTRACT and REGEXP_REPLACE
Standard SQL Regular Expression Functions:
REGEXP_CONTAINS, REGEXP_EXTRACT, REGEXP_EXTRACT_ALL and REGEXP_REPLACE
So, in your case just make sure you use proper BigQuery SQL dialect
#standardSQL
SELECT REGEXP_CONTAINS(path, r'^abc$') FROM [tablename]