mirror of https://github.com/apache/druid.git
fix segment table filter (#8034)
This commit is contained in:
parent
9c7c7c58ae
commit
2de6cc3b30
|
@ -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'"`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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()}%'`;
|
||||
}
|
||||
|
||||
// ----------------------------
|
||||
|
|
Loading…
Reference in New Issue