Selaa lähdekoodia

feat: add func

许家凯 4 vuotta sitten
vanhempi
commit
f47f0ca89e

+ 7 - 0
src/main/scala/com/winhc/bigdata/spark/utils/LoggingUtils.scala

@@ -116,6 +116,13 @@ trait LoggingUtils extends Logging {
   }
 
 
+  def dropAllPartitions(tableName: String): Unit = {
+    for (elem <- getPartitions(tableName)) {
+      sql(s"ALTER TABLE $tableName DROP IF EXISTS PARTITION(ds='$elem')")
+    }
+  }
+
+
   def getPartitions(t: String): Seq[String] = {
     val sql_s = s"show partitions " + t
     sql(sql_s).collect.toList.map(r => r.getString(0)).map(r => {