diff --git a/coral-spark/src/test/java/com/linkedin/coral/spark/CoralSparkTest.java b/coral-spark/src/test/java/com/linkedin/coral/spark/CoralSparkTest.java index 7f2b14e81..ae7801ef7 100644 --- a/coral-spark/src/test/java/com/linkedin/coral/spark/CoralSparkTest.java +++ b/coral-spark/src/test/java/com/linkedin/coral/spark/CoralSparkTest.java @@ -261,6 +261,17 @@ public void testLateralViewOuter() { assertEquals(convertToSparkSql, targetSql); } + @Test + public void testLateralViewOuterWithExtractUnion() { + RelNode relNode = TestUtils.toRelNode(String.join("\n", "", "SELECT extract_union(ut), t.ccol", "FROM complex", + "LATERAL VIEW OUTER explode(complex.c) t as ccol")); + String convertToSparkSql = createCoralSpark(relNode).getSparkSql(); + + String targetSql = "SELECT coalesce_struct(complex.ut, 'uniontype'), t0.ccol\n" + + "FROM default.complex complex LATERAL VIEW OUTER EXPLODE(complex.c) t0 AS ccol"; + assertEquals(convertToSparkSql, targetSql); + } + @Test public void testMultipleLateralView() { RelNode relNode = TestUtils.toRelNode(String.join("\n", "", "SELECT a, t.ccol, t2.ccol2", "FROM complex ", diff --git a/coral-spark/src/test/java/com/linkedin/coral/spark/TestUtils.java b/coral-spark/src/test/java/com/linkedin/coral/spark/TestUtils.java index 23ec04c8f..46cfb55da 100644 --- a/coral-spark/src/test/java/com/linkedin/coral/spark/TestUtils.java +++ b/coral-spark/src/test/java/com/linkedin/coral/spark/TestUtils.java @@ -60,7 +60,7 @@ public static void initializeViews(HiveConf conf) throws HiveException, MetaExce run(driver, "CREATE TABLE IF NOT EXISTS baz(`timestamp` int, `select` double)"); run(driver, "CREATE VIEW IF NOT EXISTS baz_view as select `select`, `timestamp` from baz"); run(driver, - "CREATE TABLE IF NOT EXISTS complex(a int, b string, c array, s struct, m map, sarr array>)"); + "CREATE TABLE IF NOT EXISTS complex(a int, b string, c array, s struct, m map, sarr array>, ut uniontype)"); String baseComplexSchema = loadSchema("base-complex.avsc"); executeCreateTableQuery(driver, "default", "basecomplex", baseComplexSchema); diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 15b54b73f..f6e70d1f4 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -9,7 +9,7 @@ def versions = [ 'jetbrains': '16.0.2', 'jline': '0.9.94', 'kryo': '2.22', - 'linkedin-calcite-core': '1.21.0.262', + 'linkedin-calcite-core': '1.21.0.265', 'pig': '0.15.0', 'spark': '2.4.0', 'spark3': '3.1.1',