You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Thomas Graves (JIRA)" <ji...@apache.org> on 2017/08/29 14:40:00 UTC
[jira] [Comment Edited] (SPARK-21841) Spark SQL doesn't pick up
column added in hive when table created with saveAsTable
[ https://issues.apache.org/jira/browse/SPARK-21841?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16145392#comment-16145392 ]
Thomas Graves edited comment on SPARK-21841 at 8/29/17 2:39 PM:
----------------------------------------------------------------
I'll try that out.
Honestly I didn't even know you could specify "hive" as a format. I actually tried to look at the docs for something like that but didn't see anything about it. Perhaps like you said we need some better docs there or perhaps I just missed it.
was (Author: tgraves):
I'll try that out.
Honestly I didn't even know you could specify "hive" as a format. I actually tried to look at the docs for something like that but didn't see anything about it. Perhaps we need some better docs there or perhaps I just missed it.
> Spark SQL doesn't pick up column added in hive when table created with saveAsTable
> ----------------------------------------------------------------------------------
>
> Key: SPARK-21841
> URL: https://issues.apache.org/jira/browse/SPARK-21841
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 2.1.0, 2.2.0
> Reporter: Thomas Graves
>
> If you create a table in Spark sql but then you modify the table in hive to add a column, spark sql doesn't pick up the new column.
> Basic example:
> {code}
> t1 = spark.sql("select ip_address from mydb.test_table limit 1")
> t1.show()
> +------------+
> | ip_address|
> +------------+
> |1.30.25.5|
> +------------+
> t1.write.saveAsTable('mydb.t1')
> In Hive:
> alter table mydb.t1 add columns (bcookie string)
> t1 = spark.table("mydb.t1")
> t1.show()
> +------------+
> | ip_address|
> +------------+
> |1.30.25.5|
> +------------+
> {code}
> It looks like its because spark sql is picking up the schema from spark.sql.sources.schema.part.0 rather then from hive.
> Interestingly enough it appears that if you create the table differently like:
> spark.sql("create table mydb.t1 select ip_address from mydb.test_table limit 1")
> Run your alter table on mydb.t1
> val t1 = spark.table("mydb.t1")
> Then it works properly.
> It looks like the difference is when it doesn't work spark.sql.sources.provider=parquet is set.
> Its doing this from createDataSourceTable where provider is parquet.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org