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错误信息
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中
(图片来源网络,侵删)
public Instance sqlRunTable(String sql) throws OdpsException { Map 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; }
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。