Commit 87e52543 by chenyuanjie

asin详情解析兼容week维度

parent b763f8f4
...@@ -40,6 +40,8 @@ class DimAsinDetail(object): ...@@ -40,6 +40,8 @@ class DimAsinDetail(object):
self.site_name = site_name self.site_name = site_name
self.date_type = date_type self.date_type = date_type
self.date_info = date_info self.date_info = date_info
# 周维度新版爬虫数据,解析逻辑与month一致
self.is_week_new_format = self.date_type == 'week' and self.date_info >= '2026-01'
self.hive_tb = f'dim_asin_detail' self.hive_tb = f'dim_asin_detail'
self.partition_dict = { self.partition_dict = {
"site_name": site_name, "site_name": site_name,
...@@ -290,7 +292,8 @@ class DimAsinDetail(object): ...@@ -290,7 +292,8 @@ class DimAsinDetail(object):
# 处理asin的变体信息 # 处理asin的变体信息
def handle_asin_variation_attribute(self): def handle_asin_variation_attribute(self):
if self.date_type in ['month', 'month_week', 'month_aba_me'] and self.date_info >= '2024-06': if (self.date_type in ['month', 'month_week', 'month_aba_me'] and self.date_info >= '2024-06') \
or self.is_week_new_format:
print("执行新版的变体信息整合") print("执行新版的变体信息整合")
variat_schema = ArrayType(ArrayType(StringType())) variat_schema = ArrayType(ArrayType(StringType()))
self.df_asin_detail = self.df_asin_detail.withColumn("variat_list_change", F.from_json(F.col("variat_list"), variat_schema)) self.df_asin_detail = self.df_asin_detail.withColumn("variat_list_change", F.from_json(F.col("variat_list"), variat_schema))
...@@ -332,7 +335,8 @@ class DimAsinDetail(object): ...@@ -332,7 +335,8 @@ class DimAsinDetail(object):
# 处理asin的配送方式信息 # 处理asin的配送方式信息
def handle_asin_buy_box_seller_type(self): def handle_asin_buy_box_seller_type(self):
if (self.date_type in ['month', 'month_week', 'month_aba_me'] and self.date_info >= '2024-05') \ if (self.date_type in ['month', 'month_week', 'month_aba_me'] and self.date_info >= '2024-05') \
or (self.date_type == '4_week' and self.date_info >= '2024-21'): or (self.date_type == '4_week' and self.date_info >= '2024-21') \
or self.is_week_new_format:
self.df_asin_detail = self.df_asin_detail.withColumn( self.df_asin_detail = self.df_asin_detail.withColumn(
'seller_json', 'seller_json',
F.when( F.when(
...@@ -482,7 +486,8 @@ class DimAsinDetail(object): ...@@ -482,7 +486,8 @@ class DimAsinDetail(object):
# 处理asin小图信息 # 处理asin小图信息
def handle_asin_img_info(self): def handle_asin_img_info(self):
if self.date_type in ['month', 'month_week', 'month_aba_me'] and self.date_info >= '2024-06': if (self.date_type in ['month', 'month_week', 'month_aba_me'] and self.date_info >= '2024-06') \
or self.is_week_new_format:
img_schema = ArrayType(ArrayType(StringType())) img_schema = ArrayType(ArrayType(StringType()))
df_asin_with_img = self.df_asin_detail.withColumn("img_list", F.from_json(F.col("img_list"), img_schema)).filter(F.size("img_list") > 0).\ df_asin_with_img = self.df_asin_detail.withColumn("img_list", F.from_json(F.col("img_list"), img_schema)).filter(F.size("img_list") > 0).\
select("asin", F.explode("img_list").alias("img_attributes")).\ select("asin", F.explode("img_list").alias("img_attributes")).\
......
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