Ver código fonte

增量修改

xufei 4 anos atrás
pai
commit
c105510111

+ 7 - 1
src/main/scala/com/winhc/bigdata/spark/utils/CompanyIncrCombineUtils.scala

@@ -70,10 +70,16 @@ case class CompanyIncrCombineUtils(s: SparkSession, source: String, target: Stri
       !s.equals("ds")
     })
 
+    //判断是否包含id字段
+    var app_sql = ""
+    if (cols.contains("id")) {
+      app_sql = " id = -1 and "
+    }
+
     //判断目标表是否之前合并过
     val list = sql(
       s"""
-         |select max(ds) max_ds from $target where id = -1 and ds > '0'
+         |select max(ds) max_ds from $target where $app_sql ds > '0'
          |""".stripMargin).collect().toList.map(_.getAs[String]("max_ds"))
 
     println(s"list: $list" + s", ds: $ds2")