You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by dz...@apache.org on 2022/10/21 11:49:16 UTC

[drill] 03/09: DRILL-8278: The period character '.' is broken in SQL LIKE patterns (#2621)

This is an automated email from the ASF dual-hosted git repository.

dzamo pushed a commit to branch 1.20
in repository https://gitbox.apache.org/repos/asf/drill.git

commit 7165163d8b300fb6079cca49bc18ad8fe9b78b8d
Author: James Turton <91...@users.noreply.github.com>
AuthorDate: Sat Aug 13 14:23:15 2022 +0200

    DRILL-8278: The period character '.' is broken in SQL LIKE patterns (#2621)
---
 .../main/java/org/apache/drill/exec/expr/fn/impl/RegexpUtil.java | 2 +-
 .../java/org/apache/drill/exec/expr/fn/impl/TestSqlPatterns.java | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/RegexpUtil.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/RegexpUtil.java
index a7f63cd5a7..d86e2588e9 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/RegexpUtil.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/RegexpUtil.java
@@ -28,7 +28,7 @@ package org.apache.drill.exec.expr.fn.impl;
  */
 
 public class RegexpUtil {
-  private static final String JAVA_REGEX_SPECIALS = "[]()|^-+*?{}$\\";
+  private static final String JAVA_REGEX_SPECIALS = "[]()|^-+*?{}$\\.";
   private static final String SQL_SIMILAR_SPECIALS = "[]()|^-+*_%?{}";
   private static final String [] REG_CHAR_CLASSES = {
       "[:ALPHA:]", "\\p{Alpha}",
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestSqlPatterns.java b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestSqlPatterns.java
index 9e5aae6c16..73db8ca739 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestSqlPatterns.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestSqlPatterns.java
@@ -159,6 +159,13 @@ public class TestSqlPatterns extends BaseTest {
     assertEquals("AB", patternInfo.getSimplePatternString());
     assertEquals(RegexpUtil.SqlPatternType.CONSTANT, patternInfo.getPatternType());
 
+    // A.B is constant. DRILL-8278
+    patternInfo = RegexpUtil.sqlToRegexLike("A.B");
+    // The . should be escaped with a \ so that it represents a literal .
+    assertEquals("A\\.B", patternInfo.getJavaPatternString());
+    assertEquals("A.B", patternInfo.getSimplePatternString());
+    assertEquals(RegexpUtil.SqlPatternType.CONSTANT, patternInfo.getPatternType());
+
     // Test with escape characters.
 
     // A%#B is invalid escape sequence
@@ -449,7 +456,7 @@ public class TestSqlPatterns extends BaseTest {
   }
 
   @Test
-  public void testSqlPatternContainsMUltipleMatchers() {
+  public void testSqlPatternContainsMultipleMatchers() {
 
     final String longASCIIString = "Drill supports a variety of NoSQL databases and file systems, including HBase, MongoDB, MapR-DB, HDFS, MapR-FS, Amazon S3, Azure Blob Storage, Google Cloud Storage, Swift, "
       + "NAS and local files. A single query can join data from multiple datastores. For example, you can join a user profile collection in MongoDB with a directory of event logs in Hadoop.";