小编Ann*_*Ann的帖子

删除存储为 orc 的 hive 表的列

我创建了如下配置单元表:

create table alpha001(id int, name string) clustered by (id) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')
Run Code Online (Sandbox Code Playgroud)

现在我想删除其中一列,比如“名称”。我尝试了以下方法:

ALTER TABLE alpha001 REPLACE COLUMNS (id int);
Run Code Online (Sandbox Code Playgroud)

结果如下

Exception thrown: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Replace columns is not supported for table default.alpha001. SerDe may be incompatible.
Run Code Online (Sandbox Code Playgroud)

和以下

Exception thrown: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Replace columns is not supported for table default.alpha001. SerDe may be incompatible.
Run Code Online (Sandbox Code Playgroud)
Exception thrown : FAILED: ParseException line 1:26 mismatched …
Run Code Online (Sandbox Code Playgroud)

hive

6
推荐指数
2
解决办法
1万
查看次数

postgres将字符串插入数字列 - 不会发生自动类型转换

postgres DB test1中有一个表有架构:在此输入图像描述

我们使用spring框架jdbcTemplate来插入数据如下:

Object[] params = {"978","tour"};

jdbcTemplate.update("insert into test1 values (?,?)", params);
Run Code Online (Sandbox Code Playgroud)

但这给出了例外:

org.springframework.jdbc.BadSqlGrammarException:PreparedStatementCallback; 错误的SQL语法[插入test1值(?,?)]; 嵌套异常是org.postgresql.util.PSQLException:错误:列"id"的类型为整数,但表达式的类型为字符变化 ERROR:列"id"的类型为整数但表达式的类型为字符变化

这适用于通过隐式类型转换的Oracle数据库,但postgres似乎不会那样工作.

这可能是postgres驱动程序的问题吗?

解决方法是显式转换:

insert into test1 values (?::numeric ,?)
Run Code Online (Sandbox Code Playgroud)

但是有更好的方法来进行转换,因为这似乎不是一个好的解决方案,因为有很多查询需要修改,而且还可能存在其他类似的转换问题.

是否有一些参数可以在DB级别设置以执行自动转换?

database postgresql casting jdbctemplate

3
推荐指数
1
解决办法
2238
查看次数

标签 统计

casting ×1

database ×1

hive ×1

jdbctemplate ×1

postgresql ×1