0 业务目的:
将oracle的存储过程业务搬迁到hive, 因此涉及不少 sql ---> hql的替换工作,基本都能实现,
hive函数不支持的oracle函数功能的就用自定义函数,遇到join的不等值连接就用mr实现,
现在说说 oracle中insert表中
insert into table f_ent_norm_statistics
select xxx , SYS_GUID() ;
oracle的SYS_GUID() 是生成32位byte的uuid,hive的rand()达不到这个目的,因此需要自定义,
这里参考下 rand源码:
@Description(name = "rand", value = "_FUNC_([seed]) - Returns a pseudorandom number between 0 and 1") @UDFType(deterministic = false) @VectorizedExpressions({FuncRandNoSeed.class, FuncRand.class}) public class UDFRand extends UDF { private Random random; private final DoubleWritable result = new DoubleWritable(); public UDFRand() { } public DoubleWritable evaluate() { if (random == null) { random = new Random(); } result.set(random.nextDouble()); return result; } public DoubleWritable evaluate(LongWritable seed) { if (random == null) { random = new Random(seed.get()); } result.set(random.nextDouble()); return result; } }
主要是
1 random = new Random(seed.get());
2 @UDFType(deterministic = false) 如果不加入这句,那么hql跑的时候只会返回一个值。
下面是我的 udf uuid写法:
/** * * @author zm * return uuid of 32bytes * eg: return F18031C69D8345DEB305D4B2E796A282 like oracle SYS_GUID() */ @UDFType(deterministic = false) public class SysGuidFun extends UDF{ public Text evaluate() { String id = UUID.randomUUID().toString(); id = id.replace("-", ""); return new Text(id); } }
相关推荐
apache-hive-2.1.1-bin.tar apache-hive-2.1.1-bin.tar apache-hive-2.1.1-bin.tarapache-hive-2.1.1-bin.tar apache-hive-2.1.1-bin.tar apache-hive-2.1.1-bin.tarapache-hive-2.1.1-bin.tar apache-hive-2.1.1-...
05.hive中如何自定义函数--json解析函数示例.mp4
含两个文件hive-jdbc-3.1.2-standalone.jar和apache-hive-3.1.2-bin.tar.gz 含两个文件hive-jdbc-3.1.2-standalone.jar和apache-hive-3.1.2-bin.tar.gz 含两个文件hive-jdbc-3.1.2-standalone.jar和apache-hive-...
02、hive-exec-2.1.1-cdh6.3.1.jar 03、hive-jdbc-2.1.1-cdh6.3.1.jar 04、hive-jdbc-2.1.1-cdh6.3.1-standalone.jar 05、hive-metastore-2.1.1-cdh6.3.1.jar 06、hive-service-2.1.1-cdh6.3.1.jar 07、libfb303-...
dbeaver连接hive时需要的驱动包hive-jdbc-uber-2.6.5.0-292.jar
01.hive内置函数--集合函数--条件控制函数.mp4
02.hive内置函数--窗口分析函数--row_number_over.mp4
09.hive内置函数--表生成函数--行转列explode--lateral-view.mp4
赠送jar包:flink-connector-hive_2.11-1.12.7.jar; 赠送原API文档:flink-connector-hive_2.11-1.12.7-javadoc.jar; 赠送源代码:flink-connector-hive_2.11-1.12.7-sources.jar; 赠送Maven依赖信息文件:flink-...
Spark不能使用hive自定义函数
hive-jdbc-3.1.2-standalone适用于linux
hive-jdbc-uber-2.6.5.0-292.jar 驱动下载,hive-jdbc-uber-2.6.5.0-292.jar,hive-jdbc-uber-2.6.5.0-292.jar
hive-jdbc-uber-2.6.5.0-292.jar驱动
hive-jdbc-uber-2.6.5.0-292.jar DbVisualizer (as of version 9.5.5) Below is an example configuration using DbVisualizer: Open the Diver Manager dialog ("Tools" > "Driver Manager...") and hit the ...
hive-jdbc-1.2.1-standalone.jar hive-jdbc驱动jar包,欢迎下载
hive-jdbc-2.3.7-standalone,可用dbeaver连接hive数据库,在工具中进行数据库记录的新增改查
Hive连接的jar包——hive-jdbc-3.1.2-standalone.jar,使用数据库连接软件连接数据仓库时需要使用相应的驱动器驱动,希望对大家有所帮助
hive-jdbc-2.1.1-cdh6.2.0(ieda等jdbc链接hive2.1.1);cdh6.2.0安装的hive2.1.1
jdbc连接hive所需的一个包 ( hive-jdbc-3.1.2.jar)
08.hive内置函数--时间-日期-字符串--函数.mp4