我在redshift中有一个表,其中有一个列名-->(代理的_next_of_kin)如果你现在看到它的名称中有一个撇号s,当我用glue将它读到我的DynamicFrame中时,它会给我上面的错误,说明语法问题。我如何才能使它工作并解决这个问题,我需要更改列名吗?或者有什么解决办法,我也试着删除列,但在将其读取到datasource0中时,似乎在删除其显示错误之前,它似乎没有到达那里。请帮助解决此问题
发布于 2021-07-29 14:13:11
尝试使用spark原生数据帧而不是动态数据帧读取数据。当我在我的列名中有空格时,我就遇到了这个问题。在使用selectExpr函数解决这个问题时,我将列名放在了反记号中。
使用spark从红移读取:
val jdbcURL = "jdbc:redshift://test-redshift.czac2vcs84ci.us-east-.redshift.amazonaws.com:5439/testredshift?user=redshift&password=W9P3GC42GJYFpGxBitxPszAc8iZFW"
val tempS3Dir = "s3n://spark-redshift-testing/temp/"
val salesDF = sqlContext.read
.format("com.databricks.spark.redshift")
.option("url", jdbcURL) //Provide the JDBC URL
.option("tempdir", tempS3Dir) //User provides a temporary S3 folder
.option("dbtable", "sales") //or use .option("query","select * from sales")
.load()https://stackoverflow.com/questions/68566622
复制相似问题