Commit c9eef618 by chenyuanjie

流量选品-account_name解析优化-与account_id配套

parent 3802fae9
...@@ -545,11 +545,11 @@ class DwtFlowAsin(Templates): ...@@ -545,11 +545,11 @@ class DwtFlowAsin(Templates):
.withColumnRenamed('account_name', 'fd_account_name') .withColumnRenamed('account_name', 'fd_account_name')
# 1. 关联df2,用于填充dim表中account_id和account_name为空的情况 # 1. 关联df2,用于填充dim表中account_id和account_name为空的情况
self.df_asin_detail = self.df_asin_detail.join(df_asin_account, on=['asin'], how='left') self.df_asin_detail = self.df_asin_detail.join(df_asin_account, on=['asin'], how='left')
# 2. 优先使用dim表中的数据(已从seller_json提取),为空则使用df2的数据 # 2. 优先使用dim表数据,account_id为空时account_id和account_name整体取fd表数据
self.df_asin_detail = self.df_asin_detail.withColumn( self.df_asin_detail = self.df_asin_detail.withColumn(
"account_id", F.coalesce(F.col("account_id"), F.col("fd_account_id")) "account_name", F.when(F.col("account_id").isNull(), F.col("fd_account_name")).otherwise(F.col("account_name"))
).withColumn( ).withColumn(
"account_name", F.coalesce(F.col("account_name"), F.col("fd_account_name")) "account_id", F.when(F.col("account_id").isNull(), F.col("fd_account_id")).otherwise(F.col("account_id"))
).drop("fd_account_id", "fd_account_name") ).drop("fd_account_id", "fd_account_name")
# 3. 关联df1获取seller_country_name # 3. 关联df1获取seller_country_name
self.df_asin_detail = self.df_asin_detail.join(df_seller_country, on=['account_id'], how='left') self.df_asin_detail = self.df_asin_detail.join(df_seller_country, on=['account_id'], how='left')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment