7474public final class HoptimatorDdlExecutor extends ServerDdlExecutor {
7575
7676 private final HoptimatorConnection connection ;
77+ private final HoptimatorConnection .HoptimatorConnectionDualLogger logger ;
7778
7879 public HoptimatorDdlExecutor (HoptimatorConnection connection ) {
7980 this .connection = connection ;
81+ this .logger = connection .getLogger (HoptimatorDdlExecutor .class );
8082 }
8183
8284 public static final SqlParserImplFactory PARSER_FACTORY = new SqlParserImplFactory () {
@@ -98,6 +100,7 @@ public DdlExecutor getDdlExecutor() {
98100 /** Executes a {@code CREATE VIEW} command. */
99101 @ Override
100102 public void execute (SqlCreateView create , CalcitePrepare .Context context ) {
103+ logger .info ("Validating statement: {}" , create );
101104 try {
102105 ValidationService .validateOrThrow (create );
103106 } catch (SQLException e ) {
@@ -133,18 +136,27 @@ public void execute(SqlCreateView create, CalcitePrepare.Context context) {
133136 RelProtoDataType protoType = RelDataTypeImpl .proto (analyzed .rowType );
134137 ViewTable viewTable = new ViewTable (Object .class , protoType , sql , schemaPath , viewPath );
135138 View view = new View (viewPath , sql );
139+ logger .info ("Validated sql statement. The view is named {} and has path {}" ,
140+ viewName , viewPath );
136141
137142 Collection <Deployer > deployers = null ;
138143 try {
144+ logger .info ("Validating view {} with deployers" , viewName );
139145 ValidationService .validateOrThrow (viewTable );
140146 deployers = DeploymentService .deployers (view , connection );
141147 ValidationService .validateOrThrow (deployers );
148+ logger .info ("Validated view {}" , viewName );
142149 if (create .getReplace ()) {
150+ logger .info ("Deploying update view {}" , viewName );
143151 DeploymentService .update (deployers );
144152 } else {
153+ logger .info ("Deploying create view {}" , viewName );
145154 DeploymentService .create (deployers );
146155 }
156+ logger .info ("Deployed view {}" , viewName );
147157 schemaPlus .add (viewName , viewTable );
158+ logger .info ("Added view {} to schema {}" , viewName , schemaPlus .getName ());
159+ logger .info ("CREATE VIEW {} completed" , viewName );
148160 } catch (Exception e ) {
149161 if (deployers != null ) {
150162 DeploymentService .restore (deployers );
@@ -158,6 +170,7 @@ public void execute(SqlCreateView create, CalcitePrepare.Context context) {
158170 /** Executes a {@code CREATE MATERIALIZED VIEW} command. */
159171 @ Override
160172 public void execute (SqlCreateMaterializedView create , CalcitePrepare .Context context ) {
173+ logger .info ("Validating statement: {}" , create );
161174 try {
162175 ValidationService .validateOrThrow (create );
163176 } catch (SQLException e ) {
@@ -214,6 +227,9 @@ public void execute(SqlCreateMaterializedView create, CalcitePrepare.Context con
214227 MaterializedViewTable materializedViewTable = new MaterializedViewTable (viewTable );
215228 RelDataType viewRowType = materializedViewTable .getRowType (typeFactory );
216229
230+ logger .info ("Validated sql statement. The view is named {} and has path {}" ,
231+ viewName , viewPath );
232+
217233 // Support "partial views", i.e. CREATE VIEW FOO$BAR, where the view name
218234 // is "foo-bar" and the sink is just FOO.
219235 String [] viewParts = viewName .split ("\\ $" , 2 );
@@ -222,6 +238,7 @@ public void execute(SqlCreateMaterializedView create, CalcitePrepare.Context con
222238 if (viewParts .length > 1 ) {
223239 pipelineName = pipelineName + "-" + viewParts [1 ];
224240 }
241+ logger .info ("Pipeline name for view {} is {}" , viewName , pipelineName );
225242 Properties connectionProperties = connection .connectionProperties ();
226243 connectionProperties .setProperty (DeploymentService .PIPELINE_OPTION , pipelineName );
227244 List <String > sinkPath = new ArrayList <>(schemaPath );
@@ -244,17 +261,23 @@ public void execute(SqlCreateMaterializedView create, CalcitePrepare.Context con
244261
245262 // Need to add the view table to the connection so that the ConnectorService can find it when resolving options.
246263 schemaPlus .add (viewName , materializedViewTable );
264+ logger .info ("Added view {} to schema {}" , viewName , schemaPlus .getName ());
247265 Pipeline pipeline = plan .pipeline (viewName , connection );
248266 MaterializedView hook = new MaterializedView (database , viewPath , sql , pipeline .job ().sql (), pipeline );
249267 // TODO support CREATE ... WITH (options...)
250268 ValidationService .validateOrThrow (hook );
251269 deployers = DeploymentService .deployers (hook , connection );
270+ logger .info ("Validating view {} with deployers" , viewName );
252271 ValidationService .validateOrThrow (deployers );
272+ logger .info ("Validated view {}" , viewName );
253273 if (create .getReplace ()) {
274+ logger .info ("Deploying update view {}" , viewName );
254275 DeploymentService .update (deployers );
255276 } else {
277+ logger .info ("Deploying create view {}" , viewName );
256278 DeploymentService .create (deployers );
257279 }
280+ logger .info ("Deployed view {}" , viewName );
258281 } catch (SQLException | RuntimeException e ) {
259282 if (deployers != null ) {
260283 DeploymentService .restore (deployers );
@@ -266,6 +289,7 @@ public void execute(SqlCreateMaterializedView create, CalcitePrepare.Context con
266289 }
267290 throw new DdlException (create , e .getMessage (), e );
268291 }
292+ logger .info ("CREATE MATERIALIZED VIEW {} completed" , viewName );
269293 }
270294
271295 // N.B. largely copy-pasted from Apache Calcite
0 commit comments