o(* ̄︶ ̄*)o

  博客园  :: 首页  ::  :: 联系 :: 订阅 订阅  :: 管理
public boolean exportDatalocal(String filePath, String sql) {
        try {
            String hql = "insert overwrite local directory '" + filePath 
                    + "' row format delimited fields terminated by ',' " 
                    + sql;
            //String hql = "insert overwrite directory '" + filePath 
            // + "' row format delimited fields terminated by ',' " 
            // + sql;

            log.info("执行hive表导出文件hql: " + hql);
            if(null == conn){
                log.info("hive 未连接");
                return false;
            }

            Statement stmt = conn.createStatement();
            log.info("连接成功: ");
            stmt.execute(hql);
            stmt.close();
        } catch (Exception e) {
            e.printStackTrace();
            log.error("hive连接失败");
            return false;
        }

        return true;
    }

执行上面的代码后,提示如下:

java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask
        at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:283)
        at om.itco.hiveaccount.hive.HiveUtils.exportDatalocal(HiveUtils.java:788)
        at com.itco.hiveaccount.job.HiveToPgTask.outdbhive(HiveToPgTask.java:170)
        at com.itco.hiveaccount.job.HiveToPgTask.run(HiveToPgTask.java:47)
        at com.itco.hiveaccount.job.HiveAccontRunning.run(HiveAccontRunning.java:220)
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:784)
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:768)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
        at com.itco.hiveaccount.HiveAccountApplication.main(HiveAccountApplication.java:27)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)

 

分析:

 这里的目录是指hive所在的机器上的目录,不是代码执行所在的机器目录。

   被这个本地目录废了两天了,丢。。。

 

posted on 2024-08-14 16:24  熊本熊の熊  阅读(16)  评论(0)    收藏  举报