Package com.alimama.mdrill.ui.service.AdhocWebServiceParams

Examples of com.alimama.mdrill.ui.service.AdhocWebServiceParams.HigoAdhocJoinParams


     
      buffer.append(" (select "+cols_inner.toString()+"  from " + projectName + " "  + sqlWhere.toString() + " ) jl1 ");
     
      for(int i=0;i<joins.length;i++)
      {
        HigoAdhocJoinParams jp=joins[i];
        buffer.append(" join ("+jp.frQuer+") jr"+i+" on (jl1."+colMap.get(jp.leftkey)+" is not null and trim(jl1."+colMap.get(jp.leftkey)+")==trim(jr"+i+"."+jp.rightkey+")) ");
      }
     
      hql=buffer.toString();
     
      StringBuffer sqlGroup = new StringBuffer();
      join = " group by ";
      for (String field : groupFields) {
        sqlGroup.append(join);
        sqlGroup.append("jl1."+colMap.get(field));
        join = ",";
      }
     
      if(AdhocWebServiceParams.hasStatFiled(showFields))
      {
        for(int i=0;i<joins.length;i++)
        {
          HigoAdhocJoinParams jp=joins[i];
          for(String s:jp.fl)
          {
            sqlGroup.append(join);
            sqlGroup.append("jr"+i+"."+s);
            join=",";
          }
        }
      }
     
      hql+=" "+sqlGroup.toString();

     
    }
   
   
   
   
     ArrayList<String> fq2list=WebServiceParams.fqListHive(true,hpart,fq2,
          isPartionByPt, filetypeMap,colMap,colMapforStatFilter,"fq2");
     if(fq2list.size()>0||orderby2!=null)
     {
        StringBuffer buffer=new StringBuffer();
        buffer.append("select * from ");
        buffer.append("("+hql+") fq2");
       
        if(fq2list.size()>0)
        {
          String join2 = " where ";
          for (String fq : fq2list) {
            buffer.append(join2);
            buffer.append(fq);
            join2 = " and ";
          }
        }
       
         if(orderby2!=null)
         {
           buffer.append(" order by "+WebServiceParams.parseFqAlias(orderby2, colMap, colMapforStatFilter, "fq2")+" "+desc2);
         }
        hql=buffer.toString();
     }
    
   

    
   
    
     if(limit >1000000)
     {
       limit=1000000;
     }
     if(limit>0)
     {
       hql=hql+" limit "+limit;
     }
    
     hql=hql.replaceAll("dist\\((.*)\\)", "count(distinct($1))");
   
 
    String md5 = MD5.getMD5(hql);
 
    SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
    String day = fmt.format(new Date());
 
    String hdpConf = (String) stormconf.get("hadoop.conf.dir");
    String connstr = (String) stormconf.get("higo.download.offline.conn");
    String uname = (String) stormconf.get("higo.download.offline.username");
    String passwd = (String) stormconf.get("higo.download.offline.passwd");
    String store = (String) stormconf.get("higo.download.offline.store")
        + "/" + day + "/" + java.util.UUID.randomUUID().toString();
    MySqlConn conn = new MySqlConn(connstr, uname, passwd);
    MysqlInfo info = new MysqlInfo(conn);
    if (username == null || username.length() <= 0) {
      username = "default";
    }
 
    StringBuffer sqlbuff = new StringBuffer();
    // int jobsize=info.getUserJobname(username, jobname, sqlbuff).size();
    sqlbuff.append(";");
    int size = info.getUser(username, true, sqlbuff).size();
    JSONObject jsonObj = new JSONObject();
    jsonObj.put("sqlbuff", sqlbuff.toString());
    jsonObj.put("size", size);
    // if(jobsize>0)
    // {
    // jsonObj.put("code", "0");
    // jsonObj.put("message", "之前已经有叫"+jobname+"的任务,请换个名字");
    // }else
    //
    if (size < 5) {
      MysqlCallback callback = new MysqlCallback(conn);
 
      String[] pcols = params == null ? new String[0] : new String(daycols
          + params.replaceAll("维度指标:", "").replaceAll("。.*$", ""))
          .split(",");
      StringBuffer liststat = new StringBuffer();
      StringBuffer listgroup = new StringBuffer();
      for (String s : pcols) {
        if (AdhocOfflineService.isStatFields(s)) {
          liststat.append(s);
          liststat.append(",");
        } else {
          listgroup.append(s);
          listgroup.append(",");
        }
      }
 
      callback.setCols((params == null || params.isEmpty()) ? cols
          .toString() : listgroup.toString() + liststat.toString());
      OfflineDownload download = new OfflineDownload();
      download.setOffline(callback);
      if (mailto == null || mailto.length() <= 0) {
        mailto = "yannian.mu@alipay.com";
      }
     
      StringBuffer setSql=new StringBuffer();
      StringBuffer cleanSql=new StringBuffer();
      for(int i=0;i<joins.length;i++)
      {
        HigoAdhocJoinParams jp=joins[i];
       
        setSql.append(jp.createSql);
        setSql.append(";");
        setSql.append(jp.addData);
        setSql.append(";");
View Full Code Here

TOP

Related Classes of com.alimama.mdrill.ui.service.AdhocWebServiceParams.HigoAdhocJoinParams

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.