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

    https://github.com/apache/spark/pull/11301#discussion_r55165012
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala 
---
    @@ -57,15 +58,15 @@ object CurrentOrigin {
     
       def reset(): Unit = value.set(Origin())
     
    -  def setPosition(line: Int, start: Int): Unit = {
    +  def setPosition(callSite: String, line: Int, start: Int): Unit = {
         value.set(
    -      value.get.copy(line = Some(line), startPosition = Some(start)))
    +      value.get.copy(callSite = Some(callSite), line = Some(line), 
startPosition = Some(start)))
       }
     
       def withOrigin[A](o: Origin)(f: => A): A = {
    +    val current = get
         set(o)
    -    val ret = try f finally { reset() }
    -    reset()
    +    val ret = try f finally { set(current) }
    --- End diff --
    
    It might correct change but I noticed that after this change, we have 
another issue when we operate `DataFrame` using both DSL like API and 
SQL/HiveQL.
    
    For example, If we have follwing code and run it.
    ```
        val df = sc.parallelize(1 to 10).toDF
        val filtered = df.filter("_1 > 4")
        val selected = filtered.select($"_1" * 10)
        selected.show()
    ```
    
    And then, we have generated code like as follows.
    
    ```
    ...
    
    /* 055 */       while (rdd_batchIdx < numRows) {
    /* 056 */         InternalRow rdd_row = rdd_batch.getRow(rdd_batchIdx++);
    /* 057 */         /* input[0, int] */
    /* 058 */         boolean rdd_isNull = rdd_row.isNullAt(0);
    /* 059 */         int rdd_value = rdd_isNull ? -1 : (rdd_row.getInt(0));
    /* 060 */         /* (input[0, int] > 4) @ filter at SPARK13432.scala:14 */
    /* 061 */         boolean filter_isNull = true;
    /* 062 */         boolean filter_value = false;
    /* 063 */         
    /* 064 */         if (!rdd_isNull) {
    /* 065 */           filter_isNull = false; // resultCode could change 
nullability.
    /* 066 */           filter_value = rdd_value > 4;
    /* 067 */           
    /* 068 */         }
    /* 069 */         if (!filter_isNull && filter_value) {
    /* 070 */           filter_metricValue.add(1);
    /* 071 */           
    /* 072 */           /* (input[0, int] * 10) @ filter at SPARK13432.scala:14 
*/
    /* 073 */           boolean project_isNull = true;
    /* 074 */           int project_value = -1;
    
    ...
    ```
    At the line #072, it should not be `filter` and the line of original code 
is not 14.
    I think, the comment should just say /* (input[0, int] * 10 */.
    
    This issue is because origin is not reset properly.



---
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