sam-1112 commented on code in PR #5415:
URL: https://github.com/apache/datafusion-comet/pull/5415#discussion_r3840489436
##########
spark/src/test/scala/org/apache/spark/sql/benchmark/CometRegExpBenchmark.scala:
##########
@@ -50,73 +51,91 @@ case class RegExpPattern(name: String, pattern: String)
*/
object CometRegExpBenchmark extends CometBenchmarkBase {
- // Patterns chosen to span common rlike shapes. Avoid Java-only constructs
- // that the native (Rust) path cannot accept, since those would be skipped
- // rather than benchmarked in the native case.
- private val patterns = List(
+ // Analyzer-admitted patterns. Default Comet exec is already native, so do
not add a
+ // "JVM regex" case: it would silently measure the native path.
+ private val inSubsetPatterns = List(
RegExpPattern("character_class", "[0-9]+"),
- RegExpPattern("anchored", "^[0-9]"),
RegExpPattern("alternation", "abc|def|ghi"),
RegExpPattern("multi_class", "[a-zA-Z][0-9]+"),
RegExpPattern("repetition", "(ab){2,}"))
+ // Analyzer-rejected, Rust-accepted. Default exec is the JVM dispatcher;
opt-in is native.
+ // Input data is ASCII (REPEAT of numeric strings) so `\d` vs `[0-9]` does
not change hits.
+ private val outOfSubsetPatterns =
List(RegExpPattern("digit_class_shorthand", "\\d+"))
+
override def runCometBenchmark(mainArgs: Array[String]): Unit = {
- runBenchmarkWithTable("rlike modes", 1024) { v =>
+ runBenchmarkWithTable("rlike modes", 1024 * 1024) { v =>
withTempPath { dir =>
withTempTable("parquetV1Table") {
prepareTable(
dir,
spark.sql(s"SELECT REPEAT(CAST(value AS STRING), 10) AS c1 FROM
$tbl"))
- patterns.foreach { p =>
+ inSubsetPatterns.foreach { p =>
+ val query = s"select c1 rlike '${p.pattern}' from parquetV1Table"
+ runBenchmark(p.name) {
+ runInSubsetModes(p.name, v, query)
+ }
+ }
+ outOfSubsetPatterns.foreach { p =>
val query = s"select c1 rlike '${p.pattern}' from parquetV1Table"
Review Comment:
Good catch — fixed in `c62b529a7`
The out-of-subset pattern is now escaped before being interpolated into the
SQL query:
```scala
val escapedPattern = p.pattern.replace("\\", "\\\\")
val query = s"select c1 rlike '$escapedPattern' from parquetV1Table"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]