def buildQuerySql(jsonobj,qp_dt):

    importType = jsonobj["sqoop.import-type"]

    if importType == "inc":

        tableName=etl_utils.buildSrcTableName(jsonobj)
        (colsStr,joinColumns,keyColumns) =  etl_utils.buildComlunmnsStrForInit(jsonobj)

        importType = jsonobj["sqoop.import-type"]

        query_template  = sqoop_import_sqlDic[importType]
        qp_dtStr = "'%s'"%(qp_dt,)
        query_sql = query_template%(qp_dtStr,colsStr,tableName)

        print "query_sql:" + query_sql

    return query_sql
def buildQuerySql(jsonobj,qp_dt):

    importType = jsonobj["sqoop.import-type"]

    if importType == "inc":
        tableName=etl_utils.buildSrcTableName(jsonobj)
       # tableName=jsonobj["db.table_name"]

       # (colsStr,joinColumns,keyColumns) =  etl_utils.buildComlunmnsStrForInit(jsonobj)
        colsList = jsonobj["columns"]
        colsStr = ""
        colsList = sorted(colsList, key=lambda column: column["columnid"])
        db_type = etl_utils.parseDBType(jsonobj)
        count = 0
 
        if len(colsList)==0:
           exit(-1)

        now_time = datetime.datetime.now()
        etl_date_str = now_time.strftime('%Y%m%d')

        for col in colsList:  
            
            colname =  etl_utils.convertColType(col,db_type)
            if count == 0:
              colsStr = colsStr + etl_date_str + ", 19000101 ," + colname
            else:
              colsStr = colsStr + "," + colname
            count = count + 1

        importType = jsonobj["sqoop.import-type"]

        query_template  = sqoop_import_sqlDic[importType]
        qp_dtStr = "'%s'"%(qp_dt,)
        query_sql = query_template%(colsStr,tableName)

        print "query_sql:" + query_sql

    return query_sql
Beispiel #3
0
def buildQuerySql(jsonobj, qp_dt):

    importType = jsonobj["sqoop.import-type"]

    if importType == "inc":
        tableName = etl_utils.buildSrcTableName(jsonobj)
        # tableName=jsonobj["db.table_name"]

        # (colsStr,joinColumns,keyColumns) =  etl_utils.buildComlunmnsStrForInit(jsonobj)
        colsList = jsonobj["columns"]
        colsStr = ""
        colsList = sorted(colsList, key=lambda column: column["columnid"])
        db_type = etl_utils.parseDBType(jsonobj)
        count = 0

        if len(colsList) == 0:
            exit(-1)

        now_time = datetime.datetime.now()
        etl_date_str = now_time.strftime('%Y%m%d')

        for col in colsList:

            colname = etl_utils.convertColType(col, db_type)
            if count == 0:
                colsStr = colsStr + etl_date_str + ", 19000101 ," + colname
            else:
                colsStr = colsStr + "," + colname
            count = count + 1

        importType = jsonobj["sqoop.import-type"]

        query_template = sqoop_import_sqlDic[importType]
        qp_dtStr = "'%s'" % (qp_dt, )
        query_sql = query_template % (colsStr, tableName)

        print "query_sql:" + query_sql

    return query_sql