Amazon redshift AWS Glue DynamicFrame尝试将空字符串写入为null

Amazon redshift AWS Glue DynamicFrame尝试将空字符串写入为null,amazon-redshift,amazon-rds,aws-glue,Amazon Redshift,Amazon Rds,Aws Glue,我有一个AWS胶水作业,将数据从RDS表移动到红移 两个表具有相同的架构: -- RDS CREATE TABLE my_table ( id varchar(256) not null primary key col1 varchar(256) not null ) -- Redshift CREATE TABLE my_table ( id varchar(256) not null col1 varchar(256) not null ) sortkey(id

我有一个AWS胶水作业,将数据从RDS表移动到红移

两个表具有相同的架构:

-- RDS
CREATE TABLE my_table (
   id varchar(256) not null primary key
   col1 varchar(256) not null
) 

-- Redshift
CREATE TABLE my_table (
   id varchar(256) not null 
   col1 varchar(256) not null
) sortkey(id)
我对这两个模式都进行了爬网,并编写了一个简单的作业来将
DynamicFrame
从RDS源写入Redshift接收器

val datasource = glueContext.getCatalogSource(
      database = "my_rds",
      tableName = "my_table",
      redshiftTmpDir = ""
    ).getDynamicFrame()

glueContext.getCatalogSink(
      database = "my_redshift",
      tableName = "my_table",
      redshiftTmpDir = "s3://some-bucket/some-path"
    ).writeDynamicFrame(datasource)
但对于空字符串值为
col1
的行,作业失败,原因是:

java.sql.SQLException:
Error (code 1213) while loading data into Redshift: "Missing data for not-null field"
Table name: my_table
Column name: col1
Column type: varchar(254)
Raw line: 3027616797,@NULL@
Raw field value: @NULL@
当我用
胶水火花壳调试时,我可以验证该值是否为空字符串
“”


我如何告诉glue区分空字符串
NULL
s?

这似乎是()中的一个问题(显然AWS glue在内部使用它)。关于这个问题有公开的门票,但已经有一年多没有碰过了:

我尝试过该代码,但结果完全相同:

datasource
  .toDF()
  .write
  .format("com.databricks.spark.redshift")
  .option("url", "<RS_JDBC_URL>?user=<USER>&password=<PASSWORD>")
  .option("dbtable", "my_table")
  .option("tempdir", "s3://S_PATH")
  .option("forward_spark_s3_credentials", "true")
  .save
数据源
.toDF()
写
.format(“com.databricks.spark.redshift”)
.option(“url”,“用户=&password=”)
.选项(“数据库表”、“我的表”)
.option(“tempdir”、“s3://S_路径”)
.选项(“转发\u spark\u s3\u凭证”,“真实”)
拯救
datasource
  .toDF()
  .write
  .format("com.databricks.spark.redshift")
  .option("url", "<RS_JDBC_URL>?user=<USER>&password=<PASSWORD>")
  .option("dbtable", "my_table")
  .option("tempdir", "s3://S_PATH")
  .option("forward_spark_s3_credentials", "true")
  .save