Skip to content

HIVE-27523 - Implement array_union UDF in Hive - #4513

Merged
saihemanth-cloudera merged 2 commits into
apache:masterfrom
tarak271:tarak-HIVE-27523
Aug 7, 2023
Merged

HIVE-27523 - Implement array_union UDF in Hive#4513
saihemanth-cloudera merged 2 commits into
apache:masterfrom
tarak271:tarak-HIVE-27523

Conversation

@tarak271

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Implement array_union function in Hive

Why are the changes needed?

This enhancement is already implemented in Spark

Does this PR introduce any user-facing change?

No

Is the change a dependency upgrade?

No

How was this patch tested?

Created Junit tests as well as qtests as part of this change

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

set hive.fetch.task.conversion=more;

DESCRIBE FUNCTION array_union;
DESCRIBE FUNCTION EXTENDED array_union;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For our info: I ran some edge cases with Spark SQL

spark-sql (default)> 
                   > SELECT array_union(array(1, 2, 3, null,3,4),array(1, 3, null));
[1,2,3,null,4]
spark-sql (default)> SELECT array_union(array(),array());
[]
spark-sql (default)> SELECT array_union(array(null),array(null));
[null]
spark-sql (default)> SELECT array_union(CAST(null AS ARRAY<INT>), CAST(null AS ARRAY<INT>));
NULL
spark-sql (default)> SELECT array_union(CAST(null AS ARRAY<INT>), ARRAY(1, 2));
NULL
spark-sql (default)> SELECT array_union(ARRAY(1, 2), CAST(null AS ARRAY<INT>));
NULL

+ " > SELECT _FUNC_(array(1, 2, 2,4), array(2,3)) FROM src LIMIT 1;\n"
+ " [1,2,3,4]")
public class GenericUDFArrayUnion extends AbstractGenericUDFArrayBase {
static final int ARRAY2_IDX = 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: This can be private

@saihemanth-cloudera saihemanth-cloudera left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

@saihemanth-cloudera
saihemanth-cloudera merged commit b9918be into apache:master Aug 7, 2023
tarak271 added a commit to tarak271/hive-1 that referenced this pull request Dec 19, 2023
…Rama Rao Lethavadla, reviewed by Okumin, Sai Hemanth Gantasala)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants