Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7566#discussion_r35290676
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/StringFunctionsSuite.scala ---
    @@ -57,19 +57,27 @@ class StringFunctionsSuite extends QueryTest {
       }
     
       test("string regex_replace / regex_extract") {
    -    val df = Seq(("100-200", "")).toDF("a", "b")
    +    val df = Seq(
    +      ("100-200", "(\\d+)-(\\d+)", "300"),
    +      ("100-200", "(\\d+)-(\\d+)", "400"),
    +      ("100-200", "(\\d+)", "400")).toDF("a", "b", "c")
     
         checkAnswer(
           df.select(
             regexp_replace($"a", "(\\d+)", "num"),
             regexp_extract($"a", "(\\d+)-(\\d+)", 1)),
    -      Row("num-num", "100"))
    -
    -    checkAnswer(
    -      df.selectExpr(
    -        "regexp_replace(a, '(\\d+)', 'num')",
    -        "regexp_extract(a, '(\\d+)-(\\d+)', 2)"),
    -      Row("num-num", "200"))
    +      Row("num-num", "100") :: Row("num-num", "100") :: Row("num-num", 
"100") :: Nil)
    +
    +    // for testing the mutable state of the expression in code gen.
    +    // This is a hack way to enable the codegen, thus the codegen is 
enable by default,
    +    // it will still use the interpretProjection if projection followed by 
a LocalRelation,
    +    // hence we add a filter operator.
    +    // See the optimizer rule `ConvertToLocalRelation`
    +    checkAnswer(
    +      df.filter("isnotnull(a)").selectExpr(
    --- End diff --
    
    This is a hack way to enable the codegen, the reason has been placed into 
the comment above.


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