gpt4 book ai didi

java - 日期和时间戳字段的HIVE和myBatis问题

转载 作者:行者123 更新时间:2023-12-02 20:49:14 29 4
gpt4 key购买 nike

我编写了一个简单的hadoop / hive表,定义为

CREATE TABLE mike
timeOne TIMESTAMP,
timeTwo TIMESTAMP,
name STRING

然后一个myBatis映射器文件在此处插入一条如下所示的记录
<insert id="insertMikeFormDataForHadoop" parameterType="hashmap">
INSERT INTO ${tableName} (timeOne, timeTwo, name)
VALUES (#{timeOne, jdbcType=DATE}, #{timeTwo, jdbcType=DATE}, #{name})
</insert>

当我运行测试以通过此SQL插入数据时,出现这样的错误。
org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database. Cause: org.apache.hive.service.cli.HiveSQLException: Error while compiling statement: FAILED: ParseException line 2:16 mismatched input '-' expecting ) near '2017' in value row constructor
### The error may involve com.vertexinc.ve.returns.mapper.FormMapper.insertMikeFormDataForHadoop-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO mike (timeOne, timeTwo, name) VALUES (?, ?, ?)
### Cause: org.apache.hive.service.cli.HiveSQLException: Error while compiling statement: FAILED: ParseException line 2:16 mismatched input '-' expecting ) near '2017' in value row constructor

我也尝试过使用jdbcType = TIMESTAMP而不是date进行同样的错误。

我想知道我是在做错什么还是假设我不应该做的关于 hive /鹰巢和mybatis的事情。

(这是我用来说明这一点的超简单示例)。

最佳答案

原来这是 hive jdbc驱动程序1.2.1版的问题。
HivePreparedStatement中的setTimestamp有一个小的缺陷。升级驱动程序解决了该问题。

https://issues.apache.org/jira/browse/HIVE-11748

关于java - 日期和时间戳字段的HIVE和myBatis问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46610889/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com