szehon-ho commented on code in PR #58666:
URL: https://github.com/apache/spark/pull/58666#discussion_r3974672965
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Relation.scala:
##########
@@ -602,11 +609,16 @@ object DataSourceV2Relation {
val catalystColStat = ColumnStat(distinct, min, max, nullCount,
avgLen, maxLen, histogram)
- output.foreach(attribute => {
- if (attribute.name.equals(key.describe())) {
- colStats = colStats :+ (attribute -> catalystColStat)
- }
- })
+ // Only single-part references can name a top-level output attribute;
nested references
+ // (fieldNames.length > 1) have no place in the attribute-keyed
catalyst statistics.
+ val fieldNames = key.fieldNames
+ if (fieldNames.length == 1) {
+ output.foreach(attribute => {
+ if (resolver(attribute.name, fieldNames.head)) {
Review Comment:
Could this avoid attaching one statistic to every resolver match? In
case-insensitive mode, an output containing both `id` and `ID` makes either key
match both attributes, potentially giving CBO incorrect statistics. Could we
accept only a unique match, perhaps preferring an exact raw-name match, and add
a test for case-conflicting outputs?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]