use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project coral by linkedin.
the class CoralSparkTest method testLateralViewArray.
@Test
public void testLateralViewArray() {
RelNode relNode = TestUtils.toRelNode("SELECT col FROM (SELECT ARRAY('a1', 'a2') as a) tmp LATERAL VIEW EXPLODE(a) a_alias AS col");
String targetSql = "SELECT t2.col\n" + "FROM (SELECT ARRAY ('a1', 'a2') a\n" + "FROM (VALUES (0)) t (ZERO)) t0 LATERAL VIEW EXPLODE(t0.a) t2 AS col";
assertEquals(CoralSpark.create(relNode).getSparkSql(), targetSql);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project coral by linkedin.
the class CoralSparkTest method testNegationOperator.
@Test
public void testNegationOperator() {
RelNode relNode = TestUtils.toRelNode("SELECT !FALSE as a FROM foo");
String targetSql = "SELECT NOT FALSE a\n" + "FROM default.foo";
assertEquals(CoralSpark.create(relNode).getSparkSql(), targetSql);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project coral by linkedin.
the class CoralSparkTest method testCastDecimal.
@Test
public void testCastDecimal() {
RelNode relNode = TestUtils.toRelNode("SELECT CAST(a as DECIMAL(6, 2)) as casted_decimal FROM default.foo");
String targetSql = "SELECT CAST(a AS DECIMAL(6, 2)) casted_decimal\n" + "FROM default.foo";
assertEquals(CoralSpark.create(relNode).getSparkSql(), targetSql);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project coral by linkedin.
the class CoralSparkTest method testLateralViewStar.
@Test
public void testLateralViewStar() {
RelNode relNode = TestUtils.toRelNode(String.join("\n", "", "SELECT a, t.*", "FROM complex", "LATERAL VIEW explode(complex.c) t"));
String targetSql = "SELECT complex.a, t0.col\n" + "FROM default.complex LATERAL VIEW EXPLODE(complex.c) t0 AS col";
assertEquals(CoralSpark.create(relNode).getSparkSql(), targetSql);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project coral by linkedin.
the class CoralSparkTest method testGetSQLFromView.
@Test
public void testGetSQLFromView() {
String targetSql = String.join("\n", "SELECT t0.bcol, bar.x", "FROM (SELECT b bcol, SUM(c) sum_c", "FROM default.foo", "GROUP BY b) t0", "INNER JOIN default.bar ON t0.sum_c = bar.y");
RelNode relNode = TestUtils.toRelNode("default", "foo_bar_view");
CoralSpark coralSpark = CoralSpark.create(relNode);
String expandedSql = coralSpark.getSparkSql();
assertEquals(expandedSql, targetSql);
}
Aggregations