当前位置:   article > 正文

Odps执行SQL报错,提示Please set odps.sql.type.system.odps2=true to use it._please add put { "odps.sql.submit.mode" : "script"

please add put { "odps.sql.submit.mode" : "script"} for multi-statement quer

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错误信息

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

解决方案:

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

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;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/725939
推荐阅读
相关标签
  

闽ICP备14008679号