zoukankan      html  css  js  c++  java
  • DBInputFormat 不支持oracle

    今天弄个MapRecord 去数据库取数据 发现一直报错,

    13/08/07 14:54:47 INFO mapred.JobClient: Task Id : attempt_201308070937_0009_m_000000_0, Status : FAILED
    java.io.IOException: ORA-00933: SQL command not properly ended
    
    	at org.apache.hadoop.mapred.lib.db.DBInputFormat.getRecordReader(DBInputFormat.java:289)
    	at org.apache.hadoop.mapred.MapTask$TrackedRecordReader.<init>(MapTask.java:197)
    	at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:418)
    	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:372)
    	at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.security.auth.Subject.doAs(Subject.java:415)
    	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
    	at org.apache.hadoop.mapred.Child.main(Child.java:249)
    
    13/08/07 14:54:47 INFO mapred.JobClient: Task Id : attempt_201308070937_0009_m_000001_0, Status : FAILED
    java.io.IOException: ORA-00933: SQL command not properly ended
    
    	at org.apache.hadoop.mapred.lib.db.DBInputFormat.getRecordReader(DBInputFormat.java:289)
    	at org.apache.hadoop.mapred.MapTask$TrackedRecordReader.<init>(MapTask.java:197)
    	at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:418)
    	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:372)
    	at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.security.auth.Subject.doAs(Subject.java:415)
    	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
    	at org.apache.hadoop.mapred.Child.main(Child.java:249)
    
    13/08/07 14:54:53 INFO mapred.JobClient: Task Id : attempt_201308070937_0009_m_000000_1, Status : FAILED
    java.io.IOException: ORA-00933: SQL command not properly ended
    
    	at org.apache.hadoop.mapred.lib.db.DBInputFormat.getRecordReader(DBInputFormat.java:289)
    	at org.apache.hadoop.mapred.MapTask$TrackedRecordReader.<init>(MapTask.java:197)
    	at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:418)
    	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:372)
    	at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.security.auth.Subject.doAs(Subject.java:415)
    	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
    	at org.apache.hadoop.mapred.Child.main(Child.java:249)
    
    13/08/07 14:54:53 INFO mapred.JobClient: Task Id : attempt_201308070937_0009_m_000001_1, Status : FAILED
    java.io.IOException: ORA-00933: SQL command not properly ended
    
    	at org.apache.hadoop.mapred.lib.db.DBInputFormat.getRecordReader(DBInputFormat.java:289)
    	at org.apache.hadoop.mapred.MapTask$TrackedRecordReader.<init>(MapTask.java:197)
    	at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:418)
    	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:372)
    	at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.security.auth.Subject.doAs(Subject.java:415)
    	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
    	at org.apache.hadoop.mapred.Child.main(Child.java:249)
    
    13/08/07 14:55:00 INFO mapred.JobClient: Task Id : attempt_201308070937_0009_m_000000_2, Status : FAILED
    java.io.IOException: ORA-00933: SQL command not properly ended
    
    	at org.apache.hadoop.mapred.lib.db.DBInputFormat.getRecordReader(DBInputFormat.java:289)
    	at org.apache.hadoop.mapred.MapTask$TrackedRecordReader.<init>(MapTask.java:197)
    	at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:418)
    	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:372)
    	at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.security.auth.Subject.doAs(Subject.java:415)
    	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
    	at org.apache.hadoop.mapred.Child.main(Child.java:249)
    
    13/08/07 14:55:02 INFO mapred.JobClient: Task Id : attempt_201308070937_0009_m_000001_2, Status : FAILED
    java.io.IOException: ORA-00933: SQL command not properly ended
    
    	at org.apache.hadoop.mapred.lib.db.DBInputFormat.getRecordReader(DBInputFormat.java:289)
    	at org.apache.hadoop.mapred.MapTask$TrackedRecordReader.<init>(MapTask.java:197)
    	at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:418)
    	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:372)
    	at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.security.auth.Subject.doAs(Subject.java:415)
    	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
    	at org.apache.hadoop.mapred.Child.main(Child.java:249)
    

      

    细心一看 原来DBInputFormat 生成 oracle SQL不对。

     /** Returns the query for selecting the records, 
         * subclasses can override this for custom behaviour.*/
        protected String getSelectQuery() {
          StringBuilder query = new StringBuilder();
          
          if(dbConf.getInputQuery() == null) {
            query.append("SELECT ");
    
            for (int i = 0; i < fieldNames.length; i++) {
              query.append(fieldNames[i]);
              if(i != fieldNames.length -1) {
                query.append(", ");
              }
            }
    
            query.append(" FROM ").append(tableName);
            query.append(" AS ").append(tableName); //in hsqldb this is necessary
            if (conditions != null && conditions.length() > 0)
              query.append(" WHERE (").append(conditions).append(")");
            String orderBy = dbConf.getInputOrderBy();
            if(orderBy != null && orderBy.length() > 0) {
              query.append(" ORDER BY ").append(orderBy);
            }
          }
          else {
            query.append(dbConf.getInputQuery());
          }
    
          try {
            query.append(" LIMIT ").append(split.getLength());
            query.append(" OFFSET ").append(split.getStart());
          }
          catch (IOException ex) {
            //ignore, will not throw
          }
          return query.toString();
        }
    

      明显是mysql 的语句。如果要支持oracle 要自己修改这个地方 编译打包   。。。。。。。。。。。。。。。。。。。

  • 相关阅读:
    Android Studio运行Hello World程序
    WPF,回车即是tab
    phpmyadmin上在某数据库里创建函数
    thinkphp项目部署在phpstudy里的nginx上
    《原创视频》牛腩学docker简记
    visual studio添加docker支持简记
    edge 浏览器中数字显示为链接
    JSON.net 在实体类中自定义日期的格式
    让easyui 的alert 消息框中的确定按钮支持空格键
    修复百度编辑器(UM)禁用时上传图片按钮还可点击的BUG;
  • 原文地址:https://www.cnblogs.com/huhai/p/3243122.html
Copyright © 2011-2022 走看看