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

Improve inefficient StringUtils.escapeLikeRegex() method

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.1.1, 2.2.0
    • SQL
    • None

    Description

      Spark's StringUtils.escapeLikeRegex() method is written inefficiently, performing tons of object allocations due to the use zip(), flatMap() , and mkString. Instead, I think method should be rewritten in an imperative style using a Java string builder.

      This method can become a performance bottleneck in cases where regex expressions are used with non-constant-foldable expressions (e.g. the regex expression comes from the data rather than being part of the query).

      Here's the code in question: https://github.com/apache/spark/blob/d785217b791882e075ad537852d49d78fc1ca31b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/StringUtils.scala#L28

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              joshrosen Josh Rosen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: