You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/01/18 07:27:46 UTC
[GitHub] [iceberg] kbendick commented on issue #2041: Out of order fields are corrupting data with Insert Into SQL on Spark 3.0
kbendick commented on issue #2041:
URL: https://github.com/apache/iceberg/issues/2041#issuecomment-762044087
If `target` is registered in the catalog, fields that need reordering can be determined via a `DESCRIBE` command or via `spark.catalog.listColumns(tableName).select("name").as[String].collect()`
We do this occasionally at my work. I can try and take a look to see if there's a cleaner approach that we might use.
```scala
val targetColumns = spark.sql("DESCRIBE EXTENDED target").select("col_name").as[String].collect()
spark.sql(s"insert into target select ${targetColumns.mkString(", ")} from input")
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org