Skip to content

Commit

Permalink
[hotfix][table] Replace TableConfig constructor with getDefault()
Browse files Browse the repository at this point in the history
  • Loading branch information
matriv authored and twalthr committed Mar 18, 2022
1 parent 9fa08be commit a924c67
Show file tree
Hide file tree
Showing 27 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/** Plan tests for HBase connector, for example, testing projection push down. */
public class HBaseTablePlanTest extends TableTestBase {

private final StreamTableTestUtil util = streamTestUtil(new TableConfig());
private final StreamTableTestUtil util = streamTestUtil(TableConfig.getDefault());

@Test
public void testMultipleRowKey() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/** Plan tests for HBase connector, for example, testing projection push down. */
public class HBaseTablePlanTest extends TableTestBase {

private final StreamTableTestUtil util = streamTestUtil(new TableConfig());
private final StreamTableTestUtil util = streamTestUtil(TableConfig.getDefault());

@Test
public void testMultipleRowKey() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/** Plan tests for JDBC connector, for example, testing projection push down. */
public class JdbcTablePlanTest extends TableTestBase {

private final StreamTableTestUtil util = streamTestUtil(new TableConfig());
private final StreamTableTestUtil util = streamTestUtil(TableConfig.getDefault());

@Before
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testRetractStreamDoesNotOverwriteTableConfig() {

private StreamTableEnvironmentImpl getStreamTableEnvironment(
StreamExecutionEnvironment env, DataStreamSource<Integer> elements) {
TableConfig tableConfig = new TableConfig();
TableConfig tableConfig = TableConfig.getDefault();
CatalogManager catalogManager = CatalogManagerMocks.createEmptyCatalogManager();
ModuleManager moduleManager = new ModuleManager();
return new StreamTableEnvironmentImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public static TableEnvironmentImpl create(EnvironmentSettings settings) {
final Executor executor = executorFactory.create(settings.getConfiguration());

// use configuration to init table config
final TableConfig tableConfig = new TableConfig();
final TableConfig tableConfig = TableConfig.getDefault();
tableConfig.setRootConfiguration(executor.getConfiguration());
tableConfig.addConfiguration(settings.getConfiguration());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class TableConfigTest {

@Rule public ExpectedException expectedException = ExpectedException.none();

private static TableConfig configByMethod = new TableConfig();
private static TableConfig configByConfiguration = new TableConfig();
private static TableConfig configByMethod = TableConfig.getDefault();
private static TableConfig configByConfiguration = TableConfig.getDefault();
private static Configuration configuration = new Configuration();

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public TestSpec equalTo(ResolvedExpression... resolvedExpressions) {

public ExpressionResolver getResolver() {
return ExpressionResolver.resolverFor(
new TableConfig(),
TableConfig.getDefault(),
name -> Optional.empty(),
new FunctionLookupMock(functions),
new DataTypeFactoryMock(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public TestSpec expectValidationException(String message) {

public OperationTreeBuilder getTreeBuilder() {
return OperationTreeBuilder.create(
new TableConfig(),
TableConfig.getDefault(),
new FunctionLookupMock(Collections.emptyMap()),
new DataTypeFactoryMock(),
name -> Optional.empty(), // do not support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class ExpressionResolverMocks {

public static ExpressionResolverBuilder forSqlExpression(SqlExpressionResolver resolver) {
return ExpressionResolver.resolverFor(
new TableConfig(),
TableConfig.getDefault(),
name -> Optional.empty(),
new FunctionLookupMock(Collections.emptyMap()),
new DataTypeFactoryMock(),
Expand All @@ -55,7 +55,7 @@ public static ExpressionResolverBuilder dummyResolver() {
public static ExpressionResolverBuilder basicResolver(
CatalogManager catalogManager, FunctionCatalog functionCatalog, Parser parser) {
return ExpressionResolver.resolverFor(
new TableConfig(),
TableConfig.getDefault(),
name -> Optional.empty(),
functionCatalog.asLookup(parser::parseIdentifier),
catalogManager.getDataTypeFactory(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class StreamTableEnvironmentImplTest {
private def getStreamTableEnvironment(
env: StreamExecutionEnvironment,
elements: DataStream[Int]) = {
val config = new TableConfig
val config = TableConfig.getDefault
val catalogManager = CatalogManagerMocks.createEmptyCatalogManager()
val moduleManager = new ModuleManager
new StreamTableEnvironmentImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public static Collection<Boolean> parameters() {

private TableTestUtil getTestUtil() {
if (isStreamingMode) {
return streamTestUtil(new TableConfig());
return streamTestUtil(TableConfig.getDefault());
} else {
return batchTestUtil(new TableConfig());
return batchTestUtil(TableConfig.getDefault());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
public class ParserImplTest {

private final boolean isStreamingMode = false;
private final TableConfig tableConfig = new TableConfig();
private final TableConfig tableConfig = TableConfig.getDefault();
private final Catalog catalog = new GenericInMemoryCatalog("MockCatalog", "default");
private final CatalogManager catalogManager =
CatalogManagerMocks.preparedCatalogManager().defaultCatalog("builtin", catalog).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
/** Test for {@link ExpressionConverter}. */
public class ExpressionConverterTest {

private final TableConfig tableConfig = new TableConfig();
private final TableConfig tableConfig = TableConfig.getDefault();
private final CatalogManager catalogManager = CatalogManagerMocks.createEmptyCatalogManager();
private final ModuleManager moduleManager = new ModuleManager();
private final PlannerContext plannerContext =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
/** Test cases for {@link SqlToOperationConverter}. */
public class SqlToOperationConverterTest {
private final boolean isStreamingMode = false;
private final TableConfig tableConfig = new TableConfig();
private final TableConfig tableConfig = TableConfig.getDefault();
private final Catalog catalog = new GenericInMemoryCatalog("MockCatalog", "default");
private final CatalogManager catalogManager =
CatalogManagerMocks.preparedCatalogManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
/** Tests for {@link MultipleInputNodeCreationProcessor}. */
public class MultipleInputNodeCreationProcessorTest extends TableTestBase {

private final BatchTableTestUtil batchUtil = batchTestUtil(new TableConfig());
private final StreamTableTestUtil streamUtil = streamTestUtil(new TableConfig());
private final BatchTableTestUtil batchUtil = batchTestUtil(TableConfig.getDefault());
private final StreamTableTestUtil streamUtil = streamTestUtil(TableConfig.getDefault());

@Test
public void testIsChainableDataStreamSource() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void testTemporalTableSourceSpecSerde(TemporalTableSourceSpec spec) throw
false);

SerdeContext serdeCtx =
JsonSerdeTestUtil.configuredSerdeContext(catalogManager, new TableConfig());
JsonSerdeTestUtil.configuredSerdeContext(catalogManager, TableConfig.getDefault());

String json = JsonSerdeTestUtil.toJson(serdeCtx, spec);
TemporalTableSourceSpec actual =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

/** Test for {@link ProjectWatermarkAssignerTransposeRule}. */
public class ProjectWatermarkAssignerTransposeRuleTest extends TableTestBase {
private final StreamTableTestUtil util = streamTestUtil(new TableConfig());
private final StreamTableTestUtil util = streamTestUtil(TableConfig.getDefault());

@Before
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* PushWatermarkIntoTableSourceScanRule}.
*/
public class PushWatermarkIntoTableSourceScanRuleTest extends TableTestBase {
private final StreamTableTestUtil util = streamTestUtil(new TableConfig());
private final StreamTableTestUtil util = streamTestUtil(TableConfig.getDefault());

@Before
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* into table source.
*/
public class PushLocalAggIntoTableSourceScanRuleTest extends TableTestBase {
protected BatchTableTestUtil util = batchTestUtil(new TableConfig());
protected BatchTableTestUtil util = batchTestUtil(TableConfig.getDefault());

@Before
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ public PlannerMocks registerTemporaryTable(String tableName, Schema tableSchema)
}

public static PlannerMocks create() {
return new PlannerMocks(new TableConfig());
return new PlannerMocks(TableConfig.getDefault());
}

public static PlannerMocks create(Configuration configuration) {
TableConfig tableConfig = new TableConfig();
TableConfig tableConfig = TableConfig.getDefault();
tableConfig.addConfiguration(configuration);
return new PlannerMocks(tableConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import org.junit.Test
class WatermarkGeneratorCodeGenTest(useDefinedConstructor: Boolean) {

// mock FlinkPlannerImpl to avoid discovering TableEnvironment and Executor.
val config = new TableConfig
val config = TableConfig.getDefault
val moduleManager = new ModuleManager
val catalogManager: CatalogManager = CatalogManagerMocks.createEmptyCatalogManager()
val functionCatalog = new FunctionCatalog(config, catalogManager, moduleManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class AggCallSelectivityEstimatorTest {

private def mockScan(
statistic: FlinkStatistic = FlinkStatistic.UNKNOWN): TableScan = {
val tableConfig = new TableConfig
val tableConfig = TableConfig.getDefault
val moduleManager = new ModuleManager
val catalogManager = CatalogManagerMocks.createEmptyCatalogManager()
val rootSchema = CalciteSchema.createRootSchema(true, false).plus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import scala.collection.JavaConversions._

class FlinkRelMdHandlerTestBase {

val tableConfig = new TableConfig()
val tableConfig = TableConfig.getDefault()
val rootSchema: SchemaPlus = MetadataTestUtil.initRootSchema()

val catalogManager: CatalogManager = CatalogManagerMocks.createEmptyCatalogManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import java.util
* TODO refactor the metadata test to extract the common logic for all related tests.
*/
class RelNodeTestBase {
val tableConfig = new TableConfig()
val tableConfig = TableConfig.getDefault()
val rootSchema: SchemaPlus = CalciteSchema.createRootSchema(true, false).plus()
val catalogManager: CatalogManager = CatalogManagerMocks.createEmptyCatalogManager()
val moduleManager = new ModuleManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class PartitionPrunerTest extends RexNodeTestBase {
Map("amount" -> "200", "name" -> "Test3").asJava
).asJava

val config = new TableConfig
val config = TableConfig.getDefault
val prunedPartitions = PartitionPruner.prunePartitions(
config,
partitionFieldNames,
Expand Down Expand Up @@ -176,7 +176,7 @@ class PartitionPrunerTest extends RexNodeTestBase {
"f3" -> "2018-08-06 12:08:06.124").asJava
).asJava

val config = new TableConfig
val config = TableConfig.getDefault
config.setLocalTimeZone(ZoneOffset.ofHours(0))
val prunedPartitions = PartitionPruner.prunePartitions(
config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class BatchTestBase extends BatchAbstractTestBase {

private val settings = EnvironmentSettings.newInstance().inBatchMode().build()
private val testingTableEnv: TestingTableEnvironment = TestingTableEnvironment
.create(settings, catalogManager = None, new TableConfig)
.create(settings, catalogManager = None, TableConfig.getDefault)
val tEnv: TableEnvironment = testingTableEnv
private val planner = tEnv.asInstanceOf[TableEnvironmentImpl].getPlanner.asInstanceOf[PlannerBase]
val env: StreamExecutionEnvironment = planner.getExecEnv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ abstract class TableTestBase {
@Rule
def name: TestName = testName

def streamTestUtil(conf: TableConfig = new TableConfig): StreamTableTestUtil =
def streamTestUtil(conf: TableConfig = TableConfig.getDefault): StreamTableTestUtil =
StreamTableTestUtil(this, conf = conf)

def scalaStreamTestUtil(): ScalaStreamTableTestUtil = ScalaStreamTableTestUtil(this)

def javaStreamTestUtil(): JavaStreamTableTestUtil = JavaStreamTableTestUtil(this)

def batchTestUtil(conf: TableConfig = new TableConfig): BatchTableTestUtil =
def batchTestUtil(conf: TableConfig = TableConfig.getDefault): BatchTableTestUtil =
BatchTableTestUtil(this, conf = conf)

def scalaBatchTestUtil(): ScalaBatchTableTestUtil = ScalaBatchTableTestUtil(this)
Expand Down Expand Up @@ -1222,7 +1222,7 @@ abstract class JavaTableTestUtil(
case class StreamTableTestUtil(
test: TableTestBase,
catalogManager: Option[CatalogManager] = None,
conf: TableConfig = new TableConfig)
conf: TableConfig = TableConfig.getDefault)
extends TableTestUtil(test, isStreamingMode = true, catalogManager, conf) {

/**
Expand Down Expand Up @@ -1342,7 +1342,7 @@ case class JavaStreamTableTestUtil(test: TableTestBase) extends JavaTableTestUti
case class BatchTableTestUtil(
test: TableTestBase,
catalogManager: Option[CatalogManager] = None,
conf: TableConfig = new TableConfig)
conf: TableConfig = TableConfig.getDefault)
extends TableTestUtil(test, isStreamingMode = false, catalogManager, conf) {

def buildBatchProgram(firstProgramNameToRemove: String): Unit = {
Expand Down

0 comments on commit a924c67

Please sign in to comment.