74
74
public final class HoptimatorDdlExecutor extends ServerDdlExecutor {
75
75
76
76
private final HoptimatorConnection connection ;
77
+ private final HoptimatorConnection .HoptimatorConnectionDualLogger logger ;
77
78
78
79
public HoptimatorDdlExecutor (HoptimatorConnection connection ) {
79
80
this .connection = connection ;
81
+ this .logger = connection .getLogger (HoptimatorDdlExecutor .class );
80
82
}
81
83
82
84
public static final SqlParserImplFactory PARSER_FACTORY = new SqlParserImplFactory () {
@@ -98,6 +100,7 @@ public DdlExecutor getDdlExecutor() {
98
100
/** Executes a {@code CREATE VIEW} command. */
99
101
@ Override
100
102
public void execute (SqlCreateView create , CalcitePrepare .Context context ) {
103
+ logger .info ("Validating statement: {}" , create );
101
104
try {
102
105
ValidationService .validateOrThrow (create );
103
106
} catch (SQLException e ) {
@@ -133,18 +136,27 @@ public void execute(SqlCreateView create, CalcitePrepare.Context context) {
133
136
RelProtoDataType protoType = RelDataTypeImpl .proto (analyzed .rowType );
134
137
ViewTable viewTable = new ViewTable (Object .class , protoType , sql , schemaPath , viewPath );
135
138
View view = new View (viewPath , sql );
139
+ logger .info ("Validated sql statement. The view is named {} and has path {}" ,
140
+ viewName , viewPath );
136
141
137
142
Collection <Deployer > deployers = null ;
138
143
try {
144
+ logger .info ("Validating view {} with deployers" , viewName );
139
145
ValidationService .validateOrThrow (viewTable );
140
146
deployers = DeploymentService .deployers (view , connection );
141
147
ValidationService .validateOrThrow (deployers );
148
+ logger .info ("Validated view {}" , viewName );
142
149
if (create .getReplace ()) {
150
+ logger .info ("Deploying update view {}" , viewName );
143
151
DeploymentService .update (deployers );
144
152
} else {
153
+ logger .info ("Deploying create view {}" , viewName );
145
154
DeploymentService .create (deployers );
146
155
}
156
+ logger .info ("Deployed view {}" , viewName );
147
157
schemaPlus .add (viewName , viewTable );
158
+ logger .info ("Added view {} to schema {}" , viewName , schemaPlus .getName ());
159
+ logger .info ("CREATE VIEW {} completed" , viewName );
148
160
} catch (Exception e ) {
149
161
if (deployers != null ) {
150
162
DeploymentService .restore (deployers );
@@ -158,6 +170,7 @@ public void execute(SqlCreateView create, CalcitePrepare.Context context) {
158
170
/** Executes a {@code CREATE MATERIALIZED VIEW} command. */
159
171
@ Override
160
172
public void execute (SqlCreateMaterializedView create , CalcitePrepare .Context context ) {
173
+ logger .info ("Validating statement: {}" , create );
161
174
try {
162
175
ValidationService .validateOrThrow (create );
163
176
} catch (SQLException e ) {
@@ -214,6 +227,9 @@ public void execute(SqlCreateMaterializedView create, CalcitePrepare.Context con
214
227
MaterializedViewTable materializedViewTable = new MaterializedViewTable (viewTable );
215
228
RelDataType viewRowType = materializedViewTable .getRowType (typeFactory );
216
229
230
+ logger .info ("Validated sql statement. The view is named {} and has path {}" ,
231
+ viewName , viewPath );
232
+
217
233
// Support "partial views", i.e. CREATE VIEW FOO$BAR, where the view name
218
234
// is "foo-bar" and the sink is just FOO.
219
235
String [] viewParts = viewName .split ("\\ $" , 2 );
@@ -222,6 +238,7 @@ public void execute(SqlCreateMaterializedView create, CalcitePrepare.Context con
222
238
if (viewParts .length > 1 ) {
223
239
pipelineName = pipelineName + "-" + viewParts [1 ];
224
240
}
241
+ logger .info ("Pipeline name for view {} is {}" , viewName , pipelineName );
225
242
Properties connectionProperties = connection .connectionProperties ();
226
243
connectionProperties .setProperty (DeploymentService .PIPELINE_OPTION , pipelineName );
227
244
List <String > sinkPath = new ArrayList <>(schemaPath );
@@ -244,17 +261,23 @@ public void execute(SqlCreateMaterializedView create, CalcitePrepare.Context con
244
261
245
262
// Need to add the view table to the connection so that the ConnectorService can find it when resolving options.
246
263
schemaPlus .add (viewName , materializedViewTable );
264
+ logger .info ("Added view {} to schema {}" , viewName , schemaPlus .getName ());
247
265
Pipeline pipeline = plan .pipeline (viewName , connection );
248
266
MaterializedView hook = new MaterializedView (database , viewPath , sql , pipeline .job ().sql (), pipeline );
249
267
// TODO support CREATE ... WITH (options...)
250
268
ValidationService .validateOrThrow (hook );
251
269
deployers = DeploymentService .deployers (hook , connection );
270
+ logger .info ("Validating view {} with deployers" , viewName );
252
271
ValidationService .validateOrThrow (deployers );
272
+ logger .info ("Validated view {}" , viewName );
253
273
if (create .getReplace ()) {
274
+ logger .info ("Deploying update view {}" , viewName );
254
275
DeploymentService .update (deployers );
255
276
} else {
277
+ logger .info ("Deploying create view {}" , viewName );
256
278
DeploymentService .create (deployers );
257
279
}
280
+ logger .info ("Deployed view {}" , viewName );
258
281
} catch (SQLException | RuntimeException e ) {
259
282
if (deployers != null ) {
260
283
DeploymentService .restore (deployers );
@@ -266,6 +289,7 @@ public void execute(SqlCreateMaterializedView create, CalcitePrepare.Context con
266
289
}
267
290
throw new DdlException (create , e .getMessage (), e );
268
291
}
292
+ logger .info ("CREATE MATERIALIZED VIEW {} completed" , viewName );
269
293
}
270
294
271
295
// N.B. largely copy-pasted from Apache Calcite
0 commit comments