or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

catalog-integration.mdcode-generation.mdexpression-system.mdfunction-integration.mdindex.mdplanner-factory.mdquery-planning.md

planner-factory.mddocs/

0

# Planner Factory System

1

2

The planner factory system provides Service Provider Interface (SPI) entry points for creating and configuring planner instances within Flink's Table API ecosystem. These factories serve as the main integration points between the Blink planner and Flink's table environment.

3

4

## Capabilities

5

6

### BlinkPlannerFactory

7

8

Main factory for creating Blink planner instances, supporting both streaming and batch execution modes based on configuration properties.

9

10

```java { .api }

11

/**

12

* Factory to construct a BatchPlanner or StreamPlanner based on configuration

13

*/

14

@Internal

15

public final class BlinkPlannerFactory implements PlannerFactory {

16

17

/**

18

* Creates a planner instance based on properties and dependencies

19

* @param properties Configuration properties including streaming mode setting

20

* @param executor Executor instance for job submission

21

* @param tableConfig Table configuration settings

22

* @param functionCatalog Function catalog for UDF management

23

* @param catalogManager Catalog manager for metadata access

24

* @return StreamPlanner for streaming mode, BatchPlanner for batch mode

25

*/

26

public Planner create(

27

Map<String, String> properties,

28

Executor executor,

29

TableConfig tableConfig,

30

FunctionCatalog functionCatalog,

31

CatalogManager catalogManager);

32

33

/**

34

* Returns optional context properties for this factory

35

* @return Map containing factory class name

36

*/

37

public Map<String, String> optionalContext();

38

39

/**

40

* Returns required context properties (empty for Blink factory)

41

* @return Empty properties map

42

*/

43

public Map<String, String> requiredContext();

44

45

/**

46

* Lists configuration properties supported by this factory

47

* @return List containing STREAMING_MODE and CLASS_NAME properties

48

*/

49

public List<String> supportedProperties();

50

}

51

```

52

53

**Usage Example:**

54

55

```java

56

import org.apache.flink.table.planner.delegation.BlinkPlannerFactory;

57

import org.apache.flink.table.api.EnvironmentSettings;

58

59

// Factory is typically used internally by EnvironmentSettings

60

EnvironmentSettings settings = EnvironmentSettings.newInstance()

61

.useBlinkPlanner() // This sets BlinkPlannerFactory as the factory

62

.inStreamingMode()

63

.build();

64

65

// Manual factory usage (advanced)

66

BlinkPlannerFactory factory = new BlinkPlannerFactory();

67

Map<String, String> properties = new HashMap<>();

68

properties.put(EnvironmentSettings.STREAMING_MODE, "true");

69

70

Planner planner = factory.create(properties, executor, tableConfig,

71

functionCatalog, catalogManager);

72

```

73

74

### BlinkExecutorFactory

75

76

Factory for creating executor instances that handle job submission and execution coordination.

77

78

```java { .api }

79

/**

80

* Factory for creating executors in the Blink planner environment

81

*/

82

@Internal

83

public final class BlinkExecutorFactory implements ExecutorFactory {

84

85

/**

86

* Creates an executor instance based on configuration properties

87

* @param properties Configuration properties for executor creation

88

* @return Executor instance for job submission

89

*/

90

public Executor create(Map<String, String> properties);

91

92

/**

93

* Returns optional context properties for this factory

94

* @return Map containing factory configuration

95

*/

96

public Map<String, String> optionalContext();

97

98

/**

99

* Returns required context properties for executor creation

100

* @return Required properties map

101

*/

102

public Map<String, String> requiredContext();

103

104

/**

105

* Lists configuration properties supported by this factory

106

* @return List of supported property keys

107

*/

108

public List<String> supportedProperties();

109

}

110

```

111

112

### DefaultParserFactory

113

114

Factory for creating SQL parser instances used for parsing and validating SQL statements.

115

116

```java { .api }

117

/**

118

* Factory for creating SQL parser instances

119

*/

120

@Internal

121

public final class DefaultParserFactory implements ParserFactory {

122

123

/**

124

* Creates a parser instance for SQL statement processing

125

* @param context Parser creation context and configuration

126

* @return Parser instance for SQL parsing and validation

127

*/

128

public Parser create(ParserContext context);

129

130

/**

131

* Returns optional context properties for parser creation

132

* @return Optional context properties

133

*/

134

public Map<String, String> optionalContext();

135

136

/**

137

* Returns required context properties for parser creation

138

* @return Required context properties

139

*/

140

public Map<String, String> requiredContext();

141

142

/**

143

* Lists configuration properties supported by this parser factory

144

* @return List of supported property keys

145

*/

146

public List<String> supportedProperties();

147

}

148

```

149

150

## Configuration Properties

151

152

### Streaming Mode Configuration

153

154

Controls whether the planner operates in streaming or batch mode:

155

156

```java { .api }

157

// From EnvironmentSettings

158

public static final String STREAMING_MODE = "table.exec.mode.streaming";

159

160

// Values:

161

// "true" - Creates StreamPlanner for streaming execution

162

// "false" - Creates BatchPlanner for batch execution

163

```

164

165

### Factory Class Configuration

166

167

Specifies which planner factory to use:

168

169

```java { .api }

170

// From EnvironmentSettings

171

public static final String CLASS_NAME = "table.exec.planner-factory";

172

173

// Value: "org.apache.flink.table.planner.delegation.BlinkPlannerFactory"

174

```

175

176

## Service Provider Interface Registration

177

178

The factories are registered via Java SPI mechanism in:

179

`META-INF/services/org.apache.flink.table.factories.TableFactory`

180

181

```

182

org.apache.flink.table.planner.delegation.BlinkPlannerFactory

183

org.apache.flink.table.planner.delegation.BlinkExecutorFactory

184

org.apache.flink.table.planner.delegation.DefaultParserFactory

185

```

186

187

This registration allows Flink's table environment to automatically discover and use the Blink planner when configured appropriately.

188

189

## Integration with Environment Settings

190

191

The factory system integrates seamlessly with Flink's EnvironmentSettings:

192

193

```java

194

// Streaming mode with Blink planner

195

EnvironmentSettings streamSettings = EnvironmentSettings.newInstance()

196

.useBlinkPlanner()

197

.inStreamingMode()

198

.build();

199

200

// Batch mode with Blink planner

201

EnvironmentSettings batchSettings = EnvironmentSettings.newInstance()

202

.useBlinkPlanner()

203

.inBatchMode()

204

.build();

205

206

// Create table environment

207

StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env, streamSettings);

208

```