Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hive-udf
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
黄贵华
hive-udf
Commits
618784a6
Commit
618784a6
authored
Mar 01, 2021
by
黄贵华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StringUnionUDF
parent
2458ea52
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
build.gradle
build.gradle
+1
-1
StringUnionUDF.java
src/main/java/cn/com/duiba/udf/StringUnionUDF.java
+37
-0
No files found.
build.gradle
View file @
618784a6
...
...
@@ -39,7 +39,7 @@ dependencies {
// compileOnly('org.apache.hive:hive-exec:1.1.0-cdh5.14.0')
// compile group: 'org.apache.hive', name: 'hive-exec', version: '1.1.0'
compileOnly
(
'org.apache.hive:hive-exec:1.1.0'
)
//
compile group: 'cz.mallat.uasparser', name: 'uasparser', version: '0.6.2'
compile
group:
'cz.mallat.uasparser'
,
name:
'uasparser'
,
version:
'0.6.2'
compile
group:
'nl.basjes.parse.useragent'
,
name:
'yauaa'
,
version:
'5.21'
}
...
...
src/main/java/cn/com/duiba/udf/StringUnionUDF.java
0 → 100644
View file @
618784a6
package
cn
.
com
.
duiba
.
udf
;
import
com.google.common.collect.Lists
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.hadoop.hive.ql.exec.UDF
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
* 字符串求差值
*/
public
class
StringUnionUDF
extends
UDF
{
public
String
evaluate
(
String
stra
,
String
strb
,
String
delimiter
)
{
if
(
StringUtils
.
isBlank
(
stra
))
{
return
strb
;
}
if
(
StringUtils
.
isBlank
(
strb
))
{
return
stra
;
}
if
(
StringUtils
.
isBlank
(
delimiter
))
{
return
null
;
}
List
<
String
>
listA
=
Lists
.
newArrayList
(
StringUtils
.
split
(
stra
,
delimiter
));
List
<
String
>
listB
=
Lists
.
newArrayList
(
StringUtils
.
split
(
strb
,
delimiter
));
Set
<
String
>
set
=
new
HashSet
<>();
//用set的特性去做
set
.
addAll
(
listA
);
set
.
addAll
(
listB
);
return
StringUtils
.
join
(
set
,
delimiter
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment