Uh oh!
There was an error while loading. Please reload this page.
[Spark-4041][SQL]attributes names in table scan should converted to lowercase when compare with relation attributes - #2884
[Spark-4041][SQL]attributes names in table scan should converted to lowercase when compare with relation attributes#2884scwf wants to merge 4 commits into
Conversation
AmplabJenkins
commented
Oct 21, 2014
Can one of the admins verify this patch? |
1 similar comment
AmplabJenkins
commented
Oct 21, 2014
Can one of the admins verify this patch? |
yhuai
commented
Oct 22, 2014
Can you add a unit test? |
There was a problem hiding this comment.
Nit: it would be safer if you use _.name.toLowerCase == a.name.toLowerCase.
scwf
commented
Oct 22, 2014
@yhuai, it's hard to make a unit test for this since |
liancheng
commented
Oct 22, 2014
I think this change is generally safe. LGTM, thanks. |
SparkQA
commented
Oct 23, 2014
QA tests have started for PR 2884 at commit
|
SparkQA
commented
Oct 23, 2014
QA tests have finished for PR 2884 at commit
|
scwf
commented
Oct 23, 2014
test failed due to streaming compile error, can you retest this? |
SparkQA
commented
Oct 23, 2014
QA tests have started for PR 2884 at commit
|
SparkQA
commented
Oct 23, 2014
QA tests have finished for PR 2884 at commit
|
liancheng
commented
Oct 23, 2014
Hm, the failure was caused by a known Jenkins configuration issue. |
liancheng
commented
Oct 23, 2014
retest this please |
SparkQA
commented
Oct 23, 2014
QA tests have started for PR 2884 at commit
|
SparkQA
commented
Oct 24, 2014
QA tests have finished for PR 2884 at commit
|
AmplabJenkins
commented
Oct 24, 2014
Test PASSed. |
There was a problem hiding this comment.
Wait, should this be done by name at all? Couldn't we be using an AttributeMap from Attribute->ordinal instead?
There was a problem hiding this comment.
Yes, column names are case insensitive in hive, we should use lowercase for names in hive module(only change here is not enough, also need convert to lowercase there https://github.com/apache/spark/blob/master/sql/hive/src/main/scala/org/apache/spark/sql/hive/TableReader.scala#L273).
I think using an AttributeMap can not fix this problem, how about add a lowerName for Attribute and in hive we use this method instead?
scwf
commented
Oct 25, 2014
Added a test case for lower case issue, the test will throw NPE if not converted to lowercase |
marmbrus
commented
Oct 26, 2014
Great, thanks for finding this and adding a test. Regarding the implementation, I'd like to try to avoid doing too much string munging as its generally easy to forget to do (hence the issue). Also, in general we try to avoid looking at string names anywhere other than in analysis. This is the whole idea behind having expression ids in AttributeReferences (and the idea behind AttributeMaps). Since we can't completely get away from string names when working with Hive, what do you think about this approach: https://github.com/marmbrus/spark/compare/hiveTableScanCase I think this more cleanly isolates the need to reason about case sensitivity into the analysis phase. |
scwf
commented
Oct 27, 2014
Cool, i think this is better |
scwf
commented
Oct 27, 2014
retest this please |
SparkQA
commented
Oct 27, 2014
Test build #473 has started for PR 2884 at commit
|
SparkQA
commented
Oct 27, 2014
Test build #473 has finished for PR 2884 at commit
|
scwf
commented
Oct 27, 2014
retest this again, seems Jenkins get something wrong and failed in |
SparkQA
commented
Oct 27, 2014
Test build #475 has started for PR 2884 at commit
|
SparkQA
commented
Oct 27, 2014
QA tests have started for PR 2884 at commit
|
scwf
commented
Oct 27, 2014
|
SparkQA
commented
Oct 27, 2014
QA tests have finished for PR 2884 at commit
|
SparkQA
commented
Oct 27, 2014
Test build #475 has finished for PR 2884 at commit
|
marmbrus
commented
Oct 28, 2014
Minor comment: In the future please put SPARK-XXXX in all capitals in the title so that our merge scripts recognize it. Thanks! Thanks for working on this! Merged to master. |
In
MetastoreRelationthe attributes name is lowercase because of hive using lowercase for fields name, so we should convert attributes name in table scan lowercase inindexWhere(_.name == a.name).neededColumnIDsmay be not correct if not convert to lowercase.