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

jihao pushed a commit to branch pinot-sql-quote-fix
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git

commit 3384d1d6709cf0cbfc1f54e4c14eb776c19c962c
Author: Jihao Zhang <[email protected]>
AuthorDate: Mon Feb 22 16:05:19 2021 -0800

    [TE] Conform to standard sql requirement for quotes
---
 .../java/org/apache/pinot/thirdeye/datasource/pinot/SqlUtils.java  | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datasource/pinot/SqlUtils.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datasource/pinot/SqlUtils.java
index 5171bb8..cdd77b9 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datasource/pinot/SqlUtils.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datasource/pinot/SqlUtils.java
@@ -415,9 +415,10 @@ public class SqlUtils {
   static String quote(String value) {
     String quoteChar = "";
     if (!StringUtils.isNumeric(value)) {
-      quoteChar = "\"";
-      if (StringUtils.isEmpty(value) || value.contains(quoteChar)) {
-        quoteChar = "\'";
+      quoteChar = "\'";
+      if (value.contains(quoteChar)) {
+        // if have single quotes inside a string, it should be specified as 2 
consecutive single quotes
+        value = value.replace(quoteChar, "''");
       }
       if (value.contains(quoteChar)) {
         throw new IllegalArgumentException(String.format("Could not find quote 
char for expression: %s", value));


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to