瀏覽代碼

增量修改

xufei 4 年之前
父節點
當前提交
c105510111
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/main/scala/com/winhc/bigdata/spark/utils/CompanyIncrCombineUtils.scala

+ 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")