aboutsummaryrefslogtreecommitdiff
path: root/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java
diff options
context:
space:
mode:
authorBohdan Kazydub <bohdan.kazydub@gmail.com>2018-10-18 18:15:23 +0300
committerSorabh Hamirwasia <sorabh@apache.org>2018-11-02 08:40:31 -0700
commitf0beeafa9fd3d54dfcbe09b7eec5c7e15036d021 (patch)
treee11d7816171c80ff6790e7ebe66bb15eca09d5e9 /exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java
parentf4ef0d4bd8e290bc3b3b6a4bd45713e38e6c1edf (diff)
DRILL-6810: Disable NULL_IF_NULL NullHandling for functions with ComplexWriter
closes #1509
Diffstat (limited to 'exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java')
-rw-r--r--exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java
index 9ab09db99..d2e0020c3 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java
@@ -25,6 +25,9 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.ArrayList;
@@ -242,6 +245,33 @@ public class TestConvertFunctions extends BaseTestQuery {
}
@Test
+ public void testConvertFromJsonNullableInput() throws Exception {
+ // Contents of the generated file:
+ /*
+ {"k": "{a: 1, b: 2}"}
+ {"k": null}
+ {"k": "{c: 3}"}
+ */
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(
+ new File(dirTestWatcher.getRootDir(), "nullable_json_strings.json")))) {
+ String[] fieldValue = {"\"{a: 1, b: 2}\"", null, "\"{c: 3}\""};
+ for (String value : fieldValue) {
+ String entry = String.format("{\"k\": %s}\n", value);
+ writer.write(entry);
+ }
+ }
+
+ testBuilder()
+ .sqlQuery("select convert_from(k, 'json') as col from dfs.`nullable_json_strings.json`")
+ .unOrdered()
+ .baselineColumns("col")
+ .baselineValues(mapOf("a", 1L, "b", 2L))
+ .baselineValues(mapOf())
+ .baselineValues(mapOf("c", 3L))
+ .go();
+ }
+
+ @Test
public void testConvertToComplexJSON() throws Exception {
String result1 =