Skip to content

Commit d6118ea

Browse files
author
toutian
committed
Merge branch 'v1.5.0_dev_udf' into 'v1.5.0_dev'
add udf See merge request !19
2 parents 1193310 + 76def47 commit d6118ea

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.dtstack.flink.sql.udf;
2+
3+
import org.apache.flink.table.functions.FunctionContext;
4+
import org.apache.flink.table.functions.ScalarFunction;
5+
6+
import java.sql.Timestamp;
7+
8+
public class TimestampUdf extends ScalarFunction {
9+
@Override
10+
public void open(FunctionContext context) {
11+
}
12+
public static Timestamp eval(String timestamp) {
13+
if (timestamp.length() == 13){
14+
return new Timestamp(Long.parseLong(timestamp));
15+
}else if (timestamp.length() == 10){
16+
return new Timestamp(Long.parseLong(timestamp)*1000);
17+
} else{
18+
return Timestamp.valueOf(timestamp);
19+
}
20+
}
21+
@Override
22+
public void close() {
23+
}
24+
}

0 commit comments

Comments
 (0)