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;
}
相关推荐
Fireworkitte3 小时前
Apache POI 详解 - Java 操作 Excel/Word/PPT
java·apache·excel
weixin-a153003083163 小时前
【playwright篇】教程(十七)[html元素知识]
java·前端·html
DCTANT4 小时前
【原创】国产化适配-全量迁移MySQL数据到OpenGauss数据库
java·数据库·spring boot·mysql·opengauss
Touper.4 小时前
SpringBoot -- 自动配置原理
java·spring boot·后端
黄雪超4 小时前
JVM——函数式语法糖:如何使用Function、Stream来编写函数式程序?
java·开发语言·jvm
ThetaarSofVenice4 小时前
对象的finalization机制Test
java·开发语言·jvm
望获linux6 小时前
【实时Linux实战系列】CPU 隔离与屏蔽技术
java·linux·运维·服务器·操作系统·开源软件·嵌入式软件
JosieBook6 小时前
【Java编程动手学】使用IDEA创建第一个HelloJava程序
java·开发语言·intellij-idea
Thomas_YXQ6 小时前
Unity3D DOTS场景流式加载技术
java·开发语言·unity
summer夏1236 小时前
2025.07 做什么
java·android studio