Skip to content

[SPARK-5498][SQL][FOLLOW] add schema to table partition - #20846

Closed
liutang123 wants to merge 1 commit into
apache:masterfrom
liutang123:SPARK-5498
Closed

[SPARK-5498][SQL][FOLLOW] add schema to table partition#20846
liutang123 wants to merge 1 commit into
apache:masterfrom
liutang123:SPARK-5498

Conversation

@liutang123

@liutang123liutang123 commented Mar 16, 2018

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

When query a orc table witch some partition schemas are different from table schema, ClassCastException will occured.
reproduction:
create table test_par(a string) PARTITIONED BY (b bigint) ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.orc.OrcSerde' STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat';
ALTER TABLE test_par CHANGE a a bigint restrict; -- in hive
select * from test_par;

How was this patch tested?

manual test.

parameters: Map[String, String] = Map.empty,
stats: Option[CatalogStatistics] = None) {
stats: Option[CatalogStatistics] = None,
schema: Option[StructType] = None) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The partition schema is stored in CatalogTable . I am not very clear what is the exception you got.

@dongjoon-hyun Could you help @liutang123 investigate the issue?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, @gatorsmile . I'll take a look during weekend.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some times, partition's schema is different from the table's.

@dongjoon-hyun

Copy link
Copy Markdown
Member

@liutang123 , Spark should not do this kind of risky thing. Hive 2.3.2 also disallows incompatible schema changes like the following.

hive> CREATE TABLE test_par(a string) PARTITIONED BY (b bigint) ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.orc.OrcSerde' STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat';
OK
Time taken: 0.262 seconds
hive> ALTER TABLE test_par CHANGE a a bigint RESTRICT;
FAILED: Execution Error, return code 1fromorg.apache.hadoop.hive.ql.exec.DDLTask. Unable to alter table. The following columns have types incompatible with the existing columns in their respective positions :
a
hive>SELECT VERSION();
OK
2.3.2 r857a9fd8ad725a53bd95c1b2d6612f9b1155f44d
Time taken: 0.711 seconds, Fetched: 1 row(s)

cc @gatorsmile .

@liutang123

liutang123 commented Mar 18, 2018

Copy link
Copy Markdown
ContributorAuthor

@dongjoon-hyun, thanks for reviewing.
The exception is not thrown in ALTER TABLE.
We should prevent user to change table's column type. But, for historical data, should we do some compatible measures?

@gatorsmile

Copy link
Copy Markdown
Member

We do not allow users to change the table column type. Currently, only the column comments are allowed to change if users issue the command through Spark. However, users still can change it through Hive. Thus, nothing we can do from Spark side, right?

@dongjoon-hyun

Copy link
Copy Markdown
Member

Right, @gatorsmile .

@AmplabJenkins

Copy link
Copy Markdown

Can one of the admins verify this patch?

@wangyumwangyum mentioned this pull request Nov 10, 2018
@srowen

Copy link
Copy Markdown
Member

What JIRA was this really about?

zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 22, 2025
Closesapache#21766Closesapache#21679Closesapache#21161Closesapache#20846Closesapache#19434Closesapache#18080Closesapache#17648Closesapache#17169
Add:
Closesapache#22813Closesapache#21994Closesapache#22005Closesapache#22463
Add:
Closesapache#15899
Add:
Closesapache#22539Closesapache#21868Closesapache#21514Closesapache#21402Closesapache#21322Closesapache#21257Closesapache#20163Closesapache#19691Closesapache#18697Closesapache#18636Closesapache#17176Closesapache#23001 from wangyum/CloseStalePRs.
Authored-by: Yuming Wang <yumwang@ebay.com>
Signed-off-by: hyukjinkwon <gurwls223@apache.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@liutang123@dongjoon-hyun@gatorsmile@AmplabJenkins@srowen