You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/07/02 09:19:40 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #33170: [SPARK-35967][SQL] Update nullability based on column statistics

HyukjinKwon commented on a change in pull request #33170:
URL: https://github.com/apache/spark/pull/33170#discussion_r662870040



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/LogicalRelation.scala
##########
@@ -81,6 +81,14 @@ object LogicalRelation {
     // The v1 source may return schema containing char/varchar type. We replace char/varchar
     // with "annotated" string type here as the query engine doesn't support char/varchar yet.
     val schema = CharVarcharUtils.replaceCharVarcharWithStringInSchema(relation.schema)
-    LogicalRelation(relation, schema.toAttributes, Some(table), false)
+    val attributes = schema.toAttributes
+    val output = table.stats.map(_.colStats) match {
+      case Some(colStats) =>
+        attributes
+          .map(a => a.withNullability(colStats.get(a.name).forall(_.nullCount.forall(_ > 0L))))

Review comment:
       Hmmm .. does this mean that if a table is saved with nullable schema but the table doesn't have nulls, here the schema becomes non-nullable when we read it back?




-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org