Browse Source

优化代码

xueyiming 13 hours ago
parent
commit
900ae96608

+ 5 - 4
src/main/scala/com/aliyun/odps/spark/examples/makedata_ad/v20240718/makedata_ad_33_bucketDataFromOriginToHive_20250522.scala

@@ -231,10 +231,11 @@ object makedata_ad_33_bucketDataFromOriginToHive_20250522 {
 
               // 使用函数式方式处理所有键
               reqFeatureKeys.foreach { key =>
-                reqFeature.get(key) match {
-                  case Some(value) if value != null && value.toString.nonEmpty =>
-                    featureMap.put(key, value.toString)
-                  case _ => // 不做任何操作
+                val value = reqFeature.getString(key)
+
+                // 检查值是否非空
+                if (value != null && value.nonEmpty) {
+                  featureMap.put(key, value)
                 }
               }