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;
}
相关推荐
FrankYoou1 小时前
Jenkins 与 GitLab CI/CD 的核心对比
java·docker
麦兜*1 小时前
Spring Boot启动优化7板斧(延迟初始化、组件扫描精准打击、JVM参数调优):砍掉70%启动时间的魔鬼实践
java·jvm·spring boot·后端·spring·spring cloud·系统架构
KK溜了溜了2 小时前
JAVA-springboot 整合Redis
java·spring boot·redis
天河归来2 小时前
使用idea创建springboot单体项目
java·spring boot·intellij-idea
weixin_478689762 小时前
十大排序算法汇总
java·算法·排序算法
码荼2 小时前
学习开发之hashmap
java·python·学习·哈希算法·个人开发·小白学开发·不花钱不花时间crud
IT_10242 小时前
Spring Boot项目开发实战销售管理系统——数据库设计!
java·开发语言·数据库·spring boot·后端·oracle
ye903 小时前
银河麒麟V10服务器版 + openGuass + JDK +Tomcat
java·开发语言·tomcat
武昌库里写JAVA3 小时前
Oracle如何使用序列 Oracle序列使用教程
java·开发语言·spring boot·学习·课程设计
做题不NG4 小时前
大模型应用开发-LangChain4j
java