Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-35379

Improve InferFiltersFromConstraints rule performance when parsing spark sql

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 3.1.1
    • None
    • SQL
    • None

    Description

      InferFiltersFromConstraints rule will generates too many constraints when there are many aliases in Project, . For example:

       

      
      test("Expression explosion when analyze test") {
          RuleExecutor.resetMetrics()
          Seq((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14))
            .toDF("a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
              "k", "l", "m", "n")
            .write.saveAsTable("test")
          val df = spark.table("test")
          val df2 = df.filter("a+b+c+d+e+f+g+h+i+j+k+l+m+n > 100")
          val df3 = df2.select('a as 'a1, 'b as 'b1,
            'c as 'c1, 'd as 'd1, 'e as 'e1, 'f as 'f1,
            'g as 'g1, 'h as 'h1, 'i as 'i1, 'j as 'j1,
            'k as 'k1, 'l as 'l1, 'm as 'm1, 'n as 'n1)
          val df4 = df3.join(df2, df3("a1") === df2("a"))
          df4.explain(true)
          logWarning(RuleExecutor.dumpTimeSpent())
        }
      
      

      So we need to optimize InferFiltersFromConstraints rule to improve performance.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              wankun Wan Kun
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: