You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by fj...@apache.org on 2019/07/06 16:21:34 UTC

[incubator-druid] branch master updated: fix segment table filter (#8034)

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

fjy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 2de6cc3  fix segment table filter (#8034)
2de6cc3 is described below

commit 2de6cc3b3007a449118d5d37b4fc8da8aacc3168
Author: Vadim Ogievetsky <va...@gmail.com>
AuthorDate: Sat Jul 6 09:21:28 2019 -0700

    fix segment table filter (#8034)
---
 web-console/src/utils/general.spec.ts | 20 +++++++++++++++++++-
 web-console/src/utils/general.tsx     |  5 +++--
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/web-console/src/utils/general.spec.ts b/web-console/src/utils/general.spec.ts
index e0d1715..264554f 100644
--- a/web-console/src/utils/general.spec.ts
+++ b/web-console/src/utils/general.spec.ts
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-import { alphanumericCompare, sortWithPrefixSuffix } from './general';
+import { alphanumericCompare, sortWithPrefixSuffix, sqlQueryCustomTableFilter } from './general';
 
 describe('general', () => {
   describe('sortWithPrefixSuffix', () => {
@@ -42,4 +42,22 @@ describe('general', () => {
       ).toEqual('gefcdhba');
     });
   });
+
+  describe('sqlQueryCustomTableFilter', () => {
+    it('works', () => {
+      expect(
+        sqlQueryCustomTableFilter({
+          id: 'datasource',
+          value: `hello`,
+        }),
+      ).toMatchInlineSnapshot(`"LOWER(\\"datasource\\") LIKE LOWER('hello%')"`);
+
+      expect(
+        sqlQueryCustomTableFilter({
+          id: 'datasource',
+          value: `"hello"`,
+        }),
+      ).toMatchInlineSnapshot(`"\\"datasource\\" = 'hello'"`);
+    });
+  });
 });
diff --git a/web-console/src/utils/general.tsx b/web-console/src/utils/general.tsx
index 2e9aeac..7f13b04 100644
--- a/web-console/src/utils/general.tsx
+++ b/web-console/src/utils/general.tsx
@@ -113,9 +113,10 @@ export function sqlQueryCustomTableFilter(filter: Filter): string {
   const needleAndMode: NeedleAndMode = getNeedleAndMode(filter.value);
   const needle = needleAndMode.needle;
   if (needleAndMode.mode === 'exact') {
-    return `${columnName} = '${needle.toUpperCase()}' OR ${columnName} = '${needle.toLowerCase()}'`;
+    return `${columnName} = '${needle}'`;
+  } else {
+    return `LOWER(${columnName}) LIKE LOWER('${needle}%')`;
   }
-  return `${columnName} LIKE '${needle.toUpperCase()}%' OR ${columnName} LIKE '${needle.toLowerCase()}%'`;
 }
 
 // ----------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org