-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQL: Implement null handling for
IN(v1, v2, ...)
(#34750)
Implemented null handling for both the value tested but also for values inside the list of values tested against. The null handling is implemented for local processors, painless scripts and Lucene Terms queries making it available for `IN` expressions occuring in `SELECT`, `WHERE` and `HAVING` clauses. Closes: #34582
- Loading branch information
Marios Trivyzas
authored
Oct 24, 2018
1 parent
d5ad3de
commit 4c73854
Showing
11 changed files
with
164 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ck/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/predicate/InTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.xpack.sql.expression.predicate; | ||
|
||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.xpack.sql.expression.Literal; | ||
|
||
import java.util.Arrays; | ||
|
||
import static org.elasticsearch.xpack.sql.tree.Location.EMPTY; | ||
|
||
public class InTests extends ESTestCase { | ||
|
||
private static final Literal ONE = L(1); | ||
private static final Literal TWO = L(2); | ||
private static final Literal THREE = L(3); | ||
private static final Literal NULL = L(null); | ||
|
||
public void testInWithContainedValue() { | ||
In in = new In(EMPTY, TWO, Arrays.asList(ONE, TWO, THREE)); | ||
assertTrue(in.fold()); | ||
} | ||
|
||
public void testInWithNotContainedValue() { | ||
In in = new In(EMPTY, THREE, Arrays.asList(ONE, TWO)); | ||
assertFalse(in.fold()); | ||
} | ||
|
||
public void testHandleNullOnLeftValue() { | ||
In in = new In(EMPTY, NULL, Arrays.asList(ONE, TWO, THREE)); | ||
assertNull(in.fold()); | ||
in = new In(EMPTY, NULL, Arrays.asList(ONE, NULL, THREE)); | ||
assertNull(in.fold()); | ||
|
||
} | ||
|
||
public void testHandleNullsOnRightValue() { | ||
In in = new In(EMPTY, THREE, Arrays.asList(ONE, NULL, THREE)); | ||
assertTrue(in.fold()); | ||
in = new In(EMPTY, ONE, Arrays.asList(TWO, NULL, THREE)); | ||
assertNull(in.fold()); | ||
} | ||
|
||
private static Literal L(Object value) { | ||
return Literal.of(EMPTY, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters