[jira] [Commented] (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=16147873#comment-16147873 ] Marcelo Vanzin commented on SPARK-21841: Good to know there's a way to say "I want a proper Hive table" in 2.2, even if the API is a little confusing for the user. Too many people just use {{saveAsTable}} without really understanding what it means for Hive compatibility. It might even make more sense to not even try to save a Hive compatible table for other formats, although that might have backwards compatibility issues. > 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-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (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=16145575#comment-16145575 ] Wenchen Fan commented on SPARK-21841: - yea we support the hive format since Spark 2.2. For older spark versions, you have to use the `CREATE TABLE` statement. > 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-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (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=16145413#comment-16145413 ] Thomas Graves commented on SPARK-21841: --- sorry for so many comments, I guess this goes back to https://issues.apache.org/jira/browse/SPARK-19150 > 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-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (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=16145399#comment-16145399 ] Thomas Graves commented on SPARK-21841: --- Oh no I guess that is explicit check in spark 2.1: if (source.toLowerCase == DDLUtils.HIVE_PROVIDER) { throw new AnalysisException("Cannot create hive serde table with saveAsTable API") } Perhaps this is only supported in spark 2.2? > 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-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (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=16145396#comment-16145396 ] Thomas Graves commented on SPARK-21841: --- Unfortunately that isn't working for me, but might be something with our hive version as its a bit non-standard: scala> t1.write.format("hive").saveAsTable("mydb.t62") org.apache.spark.sql.AnalysisException: Cannot create hive serde table with saveAsTable API; at org.apache.spark.sql.DataFrameWriter.saveAsTable(DataFrameWriter.scala:363) at org.apache.spark.sql.DataFrameWriter.saveAsTable(DataFrameWriter.scala:358) ... 48 elided > 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-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (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 commented on SPARK-21841: --- 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-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (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=16145325#comment-16145325 ] Wenchen Fan commented on SPARK-21841: - This is above the data source layer. When you create a data source table, i.e. {{t1.write.saveAsTable('mydb.t1')}} , spark will keep the table schema in table properties and ignore schema updates from hive. When you create a hive serde table, i.e., {{t1.write.format("hive").saveAsTable('mydb.t1')}} , then it can work as you expect, because hive serde table will always respect table schema from hive metastore. I think the confusing part is, for `DataFrameWriter`, by default it creates parquet data source table, while for `CREATE TABLE` statement, by default it creates text hive serde table. This is due to some historical reasons, but we may need to document it more explicitly. > 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-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (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=16144540#comment-16144540 ] Marcelo Vanzin commented on SPARK-21841: "DataSource tables" (those created, in certain cases, with {{saveAsTable}}), have pretty spotty Hive compatibility. I've run into this in a recent PR (SPARK-21617) and [~smilegator] suggested having an explicit config added to ensure compatibility, although I don't think anyone is working on that. The workaround you have (using DDL SQL commands instead of doing it via Scala code) is what we have been suggesting to people for a really long time now. I haven't looked closely at the spec to see whether it covers this, but maybe this could be called out explicitly in SPARK-15689, which plans to update the DataSource APIs. > 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-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (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=16142958#comment-16142958 ] Dongjoon Hyun commented on SPARK-21841: --- Apache Spark 2.2 is the same. More worse, it seems to overwrite the existing schema if Spark do `ALTER TABLE ADD COLUMNS` then. The column added by Hive is gone away. > 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-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org