abhishekagarwal87 commented on a change in pull request #10350:
URL: https://github.com/apache/druid/pull/10350#discussion_r487077896
##########
File path:
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java
##########
@@ -1072,6 +1075,221 @@ public void testPad()
);
}
+ @Test
+ public void testContains()
+ {
+ testHelper.testExpression(
+ ContainsOperatorConversion.caseSensitive().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("spacey"),
+ testHelper.makeLiteral("there")
+ ),
+ DruidExpression.fromExpression("contains_string(\"spacey\",'there')"),
+ 1L
+ );
+
+ testHelper.testExpression(
+ ContainsOperatorConversion.caseSensitive().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("spacey"),
+ testHelper.makeLiteral("There")
+ ),
+ DruidExpression.fromExpression("contains_string(\"spacey\",'There')"),
+ 0L
+ );
+
+ testHelper.testExpression(
+ ContainsOperatorConversion.caseInsensitive().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("spacey"),
+ testHelper.makeLiteral("There")
+ ),
+ DruidExpression.fromExpression("icontains_string(\"spacey\",'There')"),
+ 1L
+ );
+
+ testHelper.testExpression(
+ ContainsOperatorConversion.caseSensitive().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeCall(
+ SqlStdOperatorTable.CONCAT,
+ testHelper.makeLiteral("what is"),
+ testHelper.makeInputRef("spacey")
+ ),
+ testHelper.makeLiteral("what")
+ ),
+ DruidExpression.fromExpression("contains_string(concat('what
is',\"spacey\"),'what')"),
+ 1L
+ );
+
+ testHelper.testExpression(
+ ContainsOperatorConversion.caseSensitive().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeCall(
+ SqlStdOperatorTable.CONCAT,
+ testHelper.makeLiteral("what is"),
+ testHelper.makeInputRef("spacey")
+ ),
+ testHelper.makeLiteral("there")
+ ),
+ DruidExpression.fromExpression("contains_string(concat('what
is',\"spacey\"),'there')"),
+ 1L
+ );
+
+ testHelper.testExpression(
+ ContainsOperatorConversion.caseInsensitive().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeCall(
+ SqlStdOperatorTable.CONCAT,
+ testHelper.makeLiteral("what is"),
+ testHelper.makeInputRef("spacey")
+ ),
+ testHelper.makeLiteral("There")
+ ),
+ DruidExpression.fromExpression("icontains_string(concat('what
is',\"spacey\"),'There')"),
+ 1L
+ );
+
+ testHelper.testExpression(
+ SqlStdOperatorTable.AND,
+ ImmutableList.of(
+ testHelper.makeCall(
+ ContainsOperatorConversion.caseSensitive().calciteOperator(),
+ testHelper.makeInputRef("spacey"),
+ testHelper.makeLiteral("there")
+ ),
+ testHelper.makeCall(
+ SqlStdOperatorTable.EQUALS,
+ testHelper.makeLiteral("yes"),
+ testHelper.makeLiteral("yes")
+ )
+ ),
+ DruidExpression.fromExpression("(contains_string(\"spacey\",'there')
&& ('yes' == 'yes'))"),
+ 1L
+ );
+
+ testHelper.testExpression(
+ SqlStdOperatorTable.AND,
+ ImmutableList.of(
+ testHelper.makeCall(
+ ContainsOperatorConversion.caseInsensitive().calciteOperator(),
+ testHelper.makeInputRef("spacey"),
+ testHelper.makeLiteral("There")
+ ),
+ testHelper.makeCall(
+ SqlStdOperatorTable.EQUALS,
+ testHelper.makeLiteral("yes"),
+ testHelper.makeLiteral("yes")
+ )
+ ),
+ DruidExpression.fromExpression("(icontains_string(\"spacey\",'There')
&& ('yes' == 'yes'))"),
Review comment:
hmm. what do you think should be the output of following in the default
mode assuming `myColumn` has empty value?
```
CONTAINS("myColumn", '')
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]