AWSGlue:在写入后保持分区列作为行值。
创始人
2024-09-25 18:31:38
0

可以使用以下代码示例在写入后保持分区列作为行值:

在您的脚本中添加以下行:

job = Job(glueContext) job.init('myjob')

Set up logging

logger = glueContext.get_logger()

Set up glue argument parser and parse arguments

glue_parser = argparse.ArgumentParser(description='Arguments for my glue job') glue_parser.add_argument('--s3_destination_path', type=str, required=True, help='S3 destination path where the data should be written') args = glue_parser.parse_args()

Set destination path

s3_destination_path = args.s3_destination_path

Create dynamic frame

input_dyf = glueContext.create_dynamic_frame.from_catalog(database="mydb", table_name="mytable")

Convert dynamic frame to data frame

input_df = input_dyf.toDF()

Write data frame as partitioned parquet files in S3

input_df.write
.partitionBy('partition_column')
.parquet(s3_destination_path)

Read partitioned parquet files from S3 as data frame

output_df = spark.read
.parquet(s3_destination_path)

Drop partition column from data frame

output_df = output_df.drop('partition_column')

Add partition column with corresponding value as row value

output_df = output_df.withColumn('partition_column', lit('value'))

Write final data frame as non-partitioned parquet file in S3

output_df.write
.parquet(s3_destination_path)

相关内容

热门资讯

关于!微信微乐自建房辅助工具,... 关于!微信微乐自建房辅助工具,微乐家乡麻将自建房辅助app(开挂自建房)方法1)微乐家乡麻将自建房辅...
大家学习交流!微信卡五星辅助器... 大家学习交流!微信卡五星辅助器,微乐小程序免费黑科技(开挂自建房)方法1、很好的工具软件,可以解锁游...
三分钟了解!微乐微信自建房辅助... 三分钟了解!微乐微信自建房辅助工具插件,微乐家乡麻将自建房辅助app(开挂自建房)工具1、三分钟了解...
一分钟教会你!微乐家乡麻将自建... 一分钟教会你!微乐家乡麻将自建房辅助app,微乐自建房脚本免费入口(开挂自建房)方法1、用户打开应用...
分享实测!微信微乐自建房辅助工... 分享实测!微信微乐自建房辅助工具,微乐自建房脚本免费入口(开挂自建房)器1、起透看视 微信微乐自建房...
重大通报!微乐自建房辅助工具脚... 重大通报!微乐自建房辅助工具脚本,微乐小程序免费黑科技(开挂自建房)app微乐自建房辅助工具脚本破解...
如何分辨真伪!微乐微信自建房辅... 如何分辨真伪!微乐微信自建房辅助工具插件,微乐小程序免费黑科技(开挂自建房)技巧1、微乐微信自建房辅...
我来教教你!微乐自建房辅助工具... 我来教教你!微乐自建房辅助工具挂,微乐家乡麻将自建房辅助app(开挂自建房)工具1、玩家可以在微乐家...
重大来袭!微乐自建房辅助工具神... 重大来袭!微乐自建房辅助工具神器,微乐小程序免费黑科技(开挂自建房)器1、游戏颠覆性的策略玩法,独创...
带你了解!微信卡五星辅助器,微... 带你了解!微信卡五星辅助器,微乐自建房脚本免费入口(开挂自建房)方法1、带你了解!微信卡五星辅助器,...