Skip to content

Commit

Permalink
[FLINK-33023][table-planner][JUnit5 Migration] Module: flink-table-pl…
Browse files Browse the repository at this point in the history
…anner (TableTestBase)
  • Loading branch information
Jiabao-Sun committed Sep 11, 2023
1 parent 034a60a commit 4542bbc
Show file tree
Hide file tree
Showing 302 changed files with 5,230 additions and 4,544 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,29 @@
import org.apache.flink.table.planner.utils.TableTestBase;
import org.apache.flink.types.Row;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.sql.Timestamp;
import java.util.Arrays;

import static org.assertj.core.api.Assertions.assertThatThrownBy;

/**
* Test Temporal join of hive tables.
*
* <p>Defining primary key only supports since hive 3.0.0, skip other versions only test in hive
* 3.1.1. To run this test, please use mvn command: mvn test -Phive-3.1.1
* -Dtest=org.apache.flink.connectors.hive.HiveTemporalJoinITCase
*/
public class HiveTemporalJoinITCase extends TableTestBase {
class HiveTemporalJoinITCase extends TableTestBase {

private static TableEnvironment tableEnv;
private static HiveCatalog hiveCatalog;

@BeforeClass
public static void setup() {
@BeforeAll
static void setup() {
if (!HiveVersionTestUtil.HIVE_310_OR_LATER) {
return;
}
Expand Down Expand Up @@ -96,24 +98,30 @@ public static void setup() {
}

@Test
public void testProcTimeTemporalJoinHiveTable() throws Exception {
void testProcTimeTemporalJoinHiveTable() throws Exception {
if (!HiveVersionTestUtil.HIVE_310_OR_LATER) {
return;
}
tableEnv.getConfig().setSqlDialect(SqlDialect.DEFAULT);
tableEnv.executeSql("insert into build values (1,'a',10),(2,'a',21),(2,'b',22),(3,'c',33)")
.await();

expectedException().expect(TableException.class);
expectedException().expectMessage("Processing-time temporal join is not supported yet.");
tableEnv.executeSql(
"select p.x, p.y, b.z from "
+ " default_catalog.default_database.probe as p "
+ " join build for system_time as of p.p as b on p.x=b.x and p.y=b.y");
assertThatThrownBy(
() ->
tableEnv.executeSql(
"select p.x, p.y, b.z from "
+ " default_catalog.default_database.probe as p "
+ " join build for system_time as of p.p as b on p.x=b.x and p.y=b.y"))
.hasMessageContaining("Processing-time temporal join is not supported yet.")
.isInstanceOf(TableException.class);
}

@Test
public void testRowTimeTemporalJoinHiveTable() throws Exception {
void testRowTimeTemporalJoinHiveTable() throws Exception {
if (!HiveVersionTestUtil.HIVE_310_OR_LATER) {
return;
}
Expand All @@ -122,19 +130,20 @@ public void testRowTimeTemporalJoinHiveTable() throws Exception {
.await();

// Streaming hive table does not support defines watermark
expectedException().expect(ValidationException.class);
expectedException()
.expectMessage(
assertThatThrownBy(
() ->
tableEnv.executeSql(
"select p.x, p.y, b.z from "
+ " default_catalog.default_database.probe as p "
+ " join build for system_time as of p.rowtime as b on p.x=b.x and p.y=b.y"))
.hasMessageContaining(
"Event-Time Temporal Table Join requires both primary key"
+ " and row time attribute in versioned table, but no row time attribute can be found.");
tableEnv.executeSql(
"select p.x, p.y, b.z from "
+ " default_catalog.default_database.probe as p "
+ " join build for system_time as of p.rowtime as b on p.x=b.x and p.y=b.y");
+ " and row time attribute in versioned table, but no row time attribute can be found.")
.isInstanceOf(ValidationException.class);
}

@AfterClass
public static void tearDown() {
@AfterAll
static void tearDown() {
if (!HiveVersionTestUtil.HIVE_310_OR_LATER) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
import org.apache.flink.table.planner.utils.StreamTableTestUtil;
import org.apache.flink.table.planner.utils.TableTestBase;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/** Test for {@link FileSystemTableSource}. */
public class FileSystemTableSourceTest extends TableTestBase {
class FileSystemTableSourceTest extends TableTestBase {

private StreamTableTestUtil util;

@Before
public void setup() {
@BeforeEach
void setup() {
util = streamTestUtil(TableConfig.getDefault());
TableEnvironment tEnv = util.getTableEnv();

Expand Down Expand Up @@ -71,12 +71,12 @@ public void setup() {
}

@Test
public void testFilterPushDown() {
void testFilterPushDown() {
util.verifyRelPlanInsert("insert into MySink select * from MyTable where a > 10");
}

@Test
public void testMetadataReading() {
void testMetadataReading() {
util.verifyRelPlanInsert(
"insert into MySink(a, b, c) select a, b, filemeta from MyTableWithMeta");
}
Expand Down
Loading

0 comments on commit 4542bbc

Please sign in to comment.