Skip to content

Commit 40d4955

Browse files
authored
Issue_542: Initialized left node with NullNode instead of null (#564)
* initialized left node with NullNode instead of null and added test for a query starting with NOT statement * asserted all results rows and removed debug output display * asserted the size of listOfRaw instead of the whole dataframe
1 parent 5a0f92f commit 40d4955

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/main/java/com/teragrep/pth10/ast/commands/logicalstatement/LogicalStatementXML.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ public Node visitDirectoryStatement(DPLParser.DirectoryStatementContext ctx) {
276276
@Override
277277
public Node visitLogicalStatement(DPLParser.LogicalStatementContext ctx) {
278278
LOGGER.info("logicalStatement (XML) incoming: <{}>", ctx.getText());
279-
Node rv = null;
280-
Node left = null;
279+
Node rv = new NullNode();
280+
Node left = new NullNode();
281281
TerminalNode leftIsTerminal = null;
282282

283283
// Visit leftmost child if it is not a terminal node

src/test/java/com/teragrep/pth10/logicalOperationTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,4 +671,29 @@ public void testMultipleIndexSourcetypeWithOr() {
671671
Assertions.assertEquals("\"raw 08\"", listOfRaw.get(3));
672672
});
673673
}
674+
675+
@Test
676+
@DisabledIfSystemProperty(
677+
named = "skipSparkTest",
678+
matches = "true"
679+
)
680+
public void testNotStatementBeforeIndex() {
681+
String query = "NOT (index=index_B OR \"raw 01\")";
682+
683+
this.streamingTestUtil.performDPLTest(query, this.testFile, res -> {
684+
List<String> listOfRaw = res
685+
.select("_raw")
686+
.orderBy("offset")
687+
.collectAsList()
688+
.stream()
689+
.map(r -> r.getAs(0).toString())
690+
.collect(Collectors.toList());
691+
Assertions.assertEquals(5, listOfRaw.size()); // 5 rows of data
692+
Assertions.assertEquals("\"raw 02\"", listOfRaw.get(0));
693+
Assertions.assertEquals("\"raw 03\"", listOfRaw.get(1));
694+
Assertions.assertEquals("\"raw 08\"", listOfRaw.get(2));
695+
Assertions.assertEquals("\"raw 09\"", listOfRaw.get(3));
696+
Assertions.assertEquals("\"raw 10\"", listOfRaw.get(4));
697+
});
698+
}
674699
}

0 commit comments

Comments
 (0)