当前位置:网站首页>SET DECIMAL_V2=FALSE及UDF ERROR: Cannot divide decimal by zero及Incompatible return types DECIMAL问题排查
SET DECIMAL_V2=FALSE及UDF ERROR: Cannot divide decimal by zero及Incompatible return types DECIMAL问题排查
2022-06-09 05:27:00 【johnny233】
概述
最近在全职负责一款数据产品的升级改造。因旧版平台的代码写得太乱,简直惨不忍睹;别说增加功能,已有问题的定位与修复都无从下手。用户提交的,在旧版平台能执行的SQL语句,在新版平台执行报错。
此为背景。
UDF ERROR: Cannot divide decimal by zero
报错信息如下:java.lang.RuntimeException: UDF ERROR: Cannot divide decimal by zero\n,问题很明显,就是select查询语句里面含有/符号,并且分母为0。
这个报错,在不同的数据集任务,即至少两个SQL中都有出现;且在旧版平台都是执行成功的。
Impala数据源
报错的SQL精简如下:
select name as 城市
,dt as 日期
,sum(price_11) as 补单已支付金额
,sum(price_10) as 补单未支付金额
,sum(price_11)/(sum(price_11) + sum(price_10)) as 补单回款率
from t group by name, dt
报错SQL是impala数据源:
在公司内部搭建可视化查询平台执行成功,执行结果截图
kudu数据源
另有SQL,相同的报错:
select c.*, c.cost/youe_count as cpcredit,
c.cost/all_youe_count as cpallcredit, c.cost/all_youe_amount as fyl
from b left join c on b.touch_date = c.dt
其数据源为:
在可视化查询平台执行失败。
经过排查,和使用的hive-jdbc依赖组件无关。旧版平台使用的hive-jdbc版本为:
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>1.1.0-cdh5.7.1</version>
</dependency>
新版平台使用的hive-jdbc版本为:
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>2.1.1-cdh6.2.1</version>
</dependency>
而是在提交hive类SQL(impala和kudu都是基于hive)之前未执行语句:SET DECIMAL_V2=FALSE。
解决方法:
// 解决换新集群select 1/0 报错
if ("org.apache.hive.jdbc.HiveDriver".equals(driver)) {
ps.executeUpdate("SET DECIMAL_V2=FALSE");
}
RuntimeException: AnalysisException: Incompatible return types ‘DECIMAL(38,15)’ and ‘DECIMAL(38,4)’ of exprs ‘’ and ‘’
另有一个SQL报错信息:
java.lang.RuntimeException: AnalysisException: Incompatible return types 'DECIMAL(38,15)' and 'DECIMAL(38,4)' of exprs 'edw.insure_policy.commission_rate' and 'project_b.insure_policy_test.commission_rate'.\n"
报错SQL如下:
select * from edw_bx.insure_policy union all select * from project_b.insure_policy_test
SET DECIMAL_V2=FALSE
A query option that changes behavior related to the DECIMAL data type.
Important:
This query option is currently unsupported. Its precise behavior is currently undefined and might change in the future.
Type: Boolean; recognized values are 1 and 0, or true and false; any other value interpreted as false
Default: false (shown as 0 in output of SET statement)
参考
边栏推荐
- 材料之kube-dns.yaml
- AspNetPager combines stored procedure paging to speed up access
- Windows uses php to start ThinkPHP project and deploy configuration
- Requests segmented downloading of files and multi-threaded downloading
- Alibaba cloud AI training camp -sql foundation 2: query and sorting
- Interview process and thread
- Design idea of three party account authorization login system
- AQS 之 CountdownLatch 源码分析
- validate-npm-package-name
- MRNA factory| quantitative detection of LNP encapsulated RNA content by ribogreen
猜你喜欢

redis 分布式锁的几种实现方式
![[C language] a quick pass operator](/img/b3/df88d5d3945b553c1bb67247eda788.jpg)
[C language] a quick pass operator

Stack

YOLOv5的Tricks | 【Trick6】学习率调整策略(One Cycle Policy、余弦退火等)
![[series of troubles caused by inaccurate positioning] Part 2: what's wrong with the weak satellite signal](/img/fa/7ceac4a1ac181636de01de46cd272b.jpg)
[series of troubles caused by inaccurate positioning] Part 2: what's wrong with the weak satellite signal

How WPS ppt pictures come out one by one

STM32 FreeRTOS task Basics

Design idea of three party account authorization login system

2022 tea artist (intermediate) examination question simulation examination question bank and simulation examination

好榛子出辽阳!
随机推荐
Alibaba cloud AI training camp -sql basics 5: window functions, etc
AQS 之 Semaphore 源码分析
Basic knowledge of deep learning: face based common expression recognition (1)
ps如何给图像加白边
When classical music meets NFT
Failed to crawl HTML into MySQL insert
An article takes you to know what token is
Myql error expression 1 of select list is not in group by claim and contains nonaggregated column
Pattern recognition big job PCA & Fisher & KNN & kmeans
Youshimu V8 projector opens the "vision" field of high fresh
AQS 之 CyclicBarrier 源码分析
Leetcode 1037.有效的回旋镖
Leetcode 929.独特的电子邮件地址
latex中\cdots后面接上句子,后面的句子格式会乱怎么回事。
csv文件读取(v3&v5)
MarathonLb的负载研究
reids 缓存与数据库数据不一致、缓存过期删除问题
[it] Fuxin PDF Keeping Tool Selection
Alibaba cloud AI training camp - machine learning 3:lightgbm
Deque of STL