Odps执行SQL报错,提示Please set odps.sql.type.system.odps2=true to use it.

Odps执行SQL报错,提示Please set odps.sql.type.system.odps2=true to use it.或提示Please add put { "odps.sql.submit.mode" : "script"} for multi-statement query in settings的解决方案

odps错误信息

java 复制代码
AnonymousSQLTask--ODPS-0130071:[1,474] Semantic analysis exception - DATE type is not enabled in current mode. 
Please set odps.sql.type.system.odps2=true to use it.
ODPS-0130071:[1,1165] Semantic analysis exception - DATE type is not enabled in current mode. 
Please set odps.sql.type.system.odps2=true to use it.

// 或提示下面的错误信息
com.aliyun.odps.OdpsException: 
Please add put { "odps.sql.submit.mode" : "script"} for multi-statement query in settings

解决方案:

在执行task前,将上面的配置信息增加进hints中

java 复制代码
public Instance sqlRunTable(String sql) throws OdpsException {
    Map<String, String> hints = new HashMap<>();
    hints.put("odps.sql.submit.mode", "script");
    hints.put("odps.sql.type.system.odps2", "true");
    SQLTask.setDefaultHints(hints);
    Instance instance = SQLTask.run(odps, sql);
    if (!instance.isSync()) {
        instance.waitForSuccess();
    }
    if (!instance.isSuccessful()) {
        log.error("ODPS执行SQL语句失败!{}", sql);
        for (String key : instance.getTaskResults().keySet()) {
            log.error("{}--{}", key, instance.getTaskResults().get(key));
        }
    }
    return instance;
}
相关推荐
2501_9130613425 分钟前
网络原理知识
java·网络
希望永不加班32 分钟前
Spring AOP 代理模式:CGLIB 与 JDK 动态代理区别
java·开发语言·后端·spring·代理模式
flushmeteor1 小时前
java的动态代理和字节码生成技术
java·动态代理·代理·字节码生成
eggwyw1 小时前
基于SpringBoot和PostGIS的云南与缅甸的千里边境线实战
java·spring boot·spring
0xDevNull1 小时前
MySQL 别名(Alias)指南:从入门到避坑
java·数据库·sql
lv__pf1 小时前
springboot原理
java·spring boot·后端
java1234_小锋1 小时前
Java高频面试题:什么是可重入锁?
java·开发语言
云烟成雨TD2 小时前
Spring AI Alibaba 1.x 系列【22】Agent 并行工具执行与超时 / 协作式取消实战
java·人工智能·spring
段小二2 小时前
服务一重启全丢了——Spring AI Alibaba Agent 三层持久化完整方案
java·后端
段小二2 小时前
Agent 自动把机票改错了,推理完全正确——这才是真正的风险
java·后端