Skip to content

Commit 15fc504

Browse files
authored
Bump Calcite to preserve LATERALs in LATERAL UNNEST calls (#542)
* extract union on lateral outer join unit test * bump calcite * fix indent * bump calcite to latest * remove print * remove unused
1 parent c51d3b5 commit 15fc504

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

coral-spark/src/test/java/com/linkedin/coral/spark/CoralSparkTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,17 @@ public void testLateralViewOuter() {
261261
assertEquals(convertToSparkSql, targetSql);
262262
}
263263

264+
@Test
265+
public void testLateralViewOuterWithExtractUnion() {
266+
RelNode relNode = TestUtils.toRelNode(String.join("\n", "", "SELECT extract_union(ut), t.ccol", "FROM complex",
267+
"LATERAL VIEW OUTER explode(complex.c) t as ccol"));
268+
String convertToSparkSql = createCoralSpark(relNode).getSparkSql();
269+
270+
String targetSql = "SELECT coalesce_struct(complex.ut, 'uniontype<int>'), t0.ccol\n"
271+
+ "FROM default.complex complex LATERAL VIEW OUTER EXPLODE(complex.c) t0 AS ccol";
272+
assertEquals(convertToSparkSql, targetSql);
273+
}
274+
264275
@Test
265276
public void testMultipleLateralView() {
266277
RelNode relNode = TestUtils.toRelNode(String.join("\n", "", "SELECT a, t.ccol, t2.ccol2", "FROM complex ",

coral-spark/src/test/java/com/linkedin/coral/spark/TestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static void initializeViews(HiveConf conf) throws HiveException, MetaExce
6060
run(driver, "CREATE TABLE IF NOT EXISTS baz(`timestamp` int, `select` double)");
6161
run(driver, "CREATE VIEW IF NOT EXISTS baz_view as select `select`, `timestamp` from baz");
6262
run(driver,
63-
"CREATE TABLE IF NOT EXISTS complex(a int, b string, c array<double>, s struct<name:string, age:int>, m map<string, int>, sarr array<struct<name:string, age:int>>)");
63+
"CREATE TABLE IF NOT EXISTS complex(a int, b string, c array<double>, s struct<name:string, age:int>, m map<string, int>, sarr array<struct<name:string, age:int>>, ut uniontype<int>)");
6464

6565
String baseComplexSchema = loadSchema("base-complex.avsc");
6666
executeCreateTableQuery(driver, "default", "basecomplex", baseComplexSchema);

gradle/dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def versions = [
99
'jetbrains': '16.0.2',
1010
'jline': '0.9.94',
1111
'kryo': '2.22',
12-
'linkedin-calcite-core': '1.21.0.262',
12+
'linkedin-calcite-core': '1.21.0.265',
1313
'pig': '0.15.0',
1414
'spark': '2.4.0',
1515
'spark3': '3.1.1',

0 commit comments

Comments
 (0)