0
AWS S3からCSVファイルを読み込み、いくつかのフィールドでヌルチェックを適用し、結果をS3として新しいものとして保存するためのスクリプトをAWS Glueに作成しました。ファイル。問題は、値がnullの場合はString型のフィールドに遭遇し、空の文字列に変換される場合です。しかし、私はこの変換が起こらないようにしています。他のすべてのデータ型については、正常に動作しています。ここでSpark SQL:null値が結果ファイルの空の文字列に変換される
は、これまでに書かれたスクリプトです:
glueContext = GlueContext(SparkContext.getOrCreate())
spark = glueContext.spark_session
# s3 output directory
output_dir = "s3://aws-glue-scripts/..."
# Data Catalog: database and table name
db_name = "sampledb"
tbl_name = "mytable"
datasource = glueContext.create_dynamic_frame.from_catalog(database = db_name, table_name = tbl_name)
datasource_df = datasource.toDF()
datasource_df.createOrReplaceTempView("myNewTable")
datasource_sql_df = spark.sql("SELECT * FROM myNewTable WHERE name IS NULL")
datasource_sql_df.show()
datasource_sql_dyf = DynamicFrame.fromDF(datasource_sql_df, glueContext, "datasource_sql_dyf")
glueContext.write_dynamic_frame.from_options(frame = datasource_sql_dyf,
connection_type = "s3", connection_options = {"path": output_dir}, format = "json")
は、誰もがこの問題を取り除くためにどのように提案してくださいことはできますか?
ありがとうございました。