Search in sources :

Example 1 with RegexpLikeOperatorConversion

use of org.apache.druid.sql.calcite.expression.builtin.RegexpLikeOperatorConversion in project druid by druid-io.

the class ExpressionsTest method testRegexpLikeAsFilter.

@Test
public void testRegexpLikeAsFilter() {
    testHelper.testFilter(new RegexpLikeOperatorConversion().calciteOperator(), ImmutableList.of(testHelper.makeInputRef("s"), testHelper.makeLiteral("f.")), Collections.emptyList(), new RegexDimFilter("s", "f.", null), true);
    testHelper.testFilter(new RegexpLikeOperatorConversion().calciteOperator(), ImmutableList.of(testHelper.makeInputRef("s"), testHelper.makeLiteral("o")), Collections.emptyList(), // Column "s" contains an 'o', but not at the beginning, so we don't match
    new RegexDimFilter("s", "o", null), true);
    testHelper.testFilter(new RegexpLikeOperatorConversion().calciteOperator(), ImmutableList.of(testHelper.makeInputRef("s"), testHelper.makeLiteral("x.")), Collections.emptyList(), new RegexDimFilter("s", "x.", null), false);
    testHelper.testFilter(new RegexpLikeOperatorConversion().calciteOperator(), ImmutableList.of(testHelper.makeInputRef("s"), testHelper.makeLiteral("")), Collections.emptyList(), new RegexDimFilter("s", "", null), true);
    testHelper.testFilter(new RegexpLikeOperatorConversion().calciteOperator(), ImmutableList.of(testHelper.makeInputRef("newliney"), testHelper.makeLiteral("^beep$")), Collections.emptyList(), new RegexDimFilter("newliney", "^beep$", null), false);
    testHelper.testFilter(new RegexpLikeOperatorConversion().calciteOperator(), ImmutableList.of(testHelper.makeInputRef("newliney"), testHelper.makeLiteral("^beep\\nboop$")), Collections.emptyList(), new RegexDimFilter("newliney", "^beep\\nboop$", null), true);
    testHelper.testFilter(new RegexpLikeOperatorConversion().calciteOperator(), ImmutableList.of(testHelper.makeCall(SqlStdOperatorTable.CONCAT, testHelper.makeLiteral("Z"), testHelper.makeInputRef("s")), testHelper.makeLiteral("x(.)")), ImmutableList.of(new ExpressionVirtualColumn("v0", "concat('Z',\"s\")", ColumnType.STRING, TestExprMacroTable.INSTANCE)), new RegexDimFilter("v0", "x(.)", null), false);
}
Also used : RegexDimFilter(org.apache.druid.query.filter.RegexDimFilter) ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) RegexpLikeOperatorConversion(org.apache.druid.sql.calcite.expression.builtin.RegexpLikeOperatorConversion) Test(org.junit.Test)

Aggregations

RegexDimFilter (org.apache.druid.query.filter.RegexDimFilter)1 ExpressionVirtualColumn (org.apache.druid.segment.virtual.ExpressionVirtualColumn)1 RegexpLikeOperatorConversion (org.apache.druid.sql.calcite.expression.builtin.RegexpLikeOperatorConversion)1 Test (org.junit.Test)1