Gabriel39 commented on code in PR #69672:
URL: https://github.com/apache/doris/pull/69672#discussion_r4398917481


##########
fe/fe-connector/fe-connector-es/src/main/java/org/apache/doris/connector/es/EsQueryDslBuilder.java:
##########
@@ -406,17 +455,11 @@ private static String 
buildComparisonDsl(ConnectorComparison.Operator op,
                 // col <=> non-null is equivalent to EQ (term queries exclude 
nulls)
                 return termQuery(column, value);
             case NE:
-                // col != '' means col.length() > 0, NULL should not appear in 
results
-                if (value instanceof String && ((String) value).isEmpty()) {
-                    ObjectNode root = MAPPER.createObjectNode();
-                    ObjectNode boolNode = root.putObject("bool");
-                    boolNode.set("must_not", parseJsonNode(termQuery(column, 
value)));
-                    boolNode.set("must", parseJsonNode(existsQuery(column)));
-                    return root.toString();
-                }
+                // SQL <> is UNKNOWN for missing values, while ES must_not 
alone matches them.
                 ObjectNode neRoot = MAPPER.createObjectNode();
                 ObjectNode neBool = neRoot.putObject("bool");
                 neBool.set("must_not", parseJsonNode(termQuery(column, 
value)));
+                neBool.set("must", parseJsonNode(existsQuery(column)));

Review Comment:
   Fixed in b2f7d3fbbcfc9006aa7004306fd0011379b7897e.
   
   Retained NOT is normalized in the connector: ordinary comparisons use their 
inverse operator, double NOT is removed, and Boolean negation distributes to 
its operands. This preserves NULL rejection instead of complementing an ES 
true-set and admitting missing rows. Unit tests cover all six inversions and 
double negation. Live tests reproduce the original NULL leak and verify 
NOT(NE), NOT(EQ), nested NOT and NOT(OR) with a native sibling while 
SIMPLIFY_NOT_EXPR is disabled; the session setting is restored.
   
   Validation: 158 FE ES tests passed (one optional ES9 class skipped), 12 BE 
unit tests passed, and four live ES8 suites passed 1,452 stored checks and 
1,356 independent comparisons. The final new fixture also passed a separate 
non-generation rerun. FE Checkstyle, clang-format 16, clang-tidy, build hygiene 
and the standard ASAN BE build passed.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to