Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17302#discussion_r107339123
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/object.scala
 ---
    @@ -41,7 +41,20 @@ object CatalystSerde {
       }
     
       def generateObjAttr[T : Encoder]: Attribute = {
    -    AttributeReference("obj", encoderFor[T].deserializer.dataType, 
nullable = false)()
    +    val deserializer = encoderFor[T].deserializer
    +    val dataType = deserializer.dataType
    +    val nullable = if (deserializer.resolved) {
    +      deserializer.nullable
    +    } else {
    +      // Since deserializer is not resolved here, cannot access 
deserializer.nullable.
    --- End diff --
    
    It is too conservative since it always returned `false`.
    
    If we just return `true`, the following code has a call to `isNullAt()` and 
its check to get a long value at lines 30 and 35 while its type is primitive.
    
    ```java
    sparkContext.parallelize(Seq(0L, 1L, 2L), 1).toDF.collect
    ```
    
    ```java
    /* 027 */   protected void processNext() throws java.io.IOException {
    /* 028 */     while (inputadapter_input.hasNext() && !stopEarly()) {
    /* 029 */       InternalRow inputadapter_row = (InternalRow) 
inputadapter_input.next();
    /* 030 */       boolean inputadapter_isNull = inputadapter_row.isNullAt(0);
    /* 031 */       long inputadapter_value = inputadapter_isNull ? -1L : 
(inputadapter_row.getLong(0));
    /* 032 */
    /* 033 */       serializefromobject_rowWriter.zeroOutNullBytes();
    /* 034 */
    /* 035 */       if (inputadapter_isNull) {
    /* 036 */         serializefromobject_rowWriter.setNullAt(0);
    /* 037 */       } else {
    /* 038 */         serializefromobject_rowWriter.write(0, 
inputadapter_value);
    /* 039 */       }
    /* 040 */       append(serializefromobject_result);
    /* 041 */       if (shouldStop()) return;
    /* 042 */     }
    /* 043 */   }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to