slinkydeveloper commented on a change in pull request #18701: URL: https://github.com/apache/flink/pull/18701#discussion_r803664883
########## File path: flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/delegation/StreamPlanner.scala ########## @@ -129,14 +134,48 @@ class StreamPlanner( new StreamPlanner(executor, config, moduleManager, functionCatalog, catalogManager) } + override def loadPlan(planReference: PlanReference): CompiledPlanInternal = { + val ctx = createSerdeContext + val objectReader: ObjectReader = JsonSerdeUtil.createObjectReader(ctx) + val execNodeGraph = planReference match { + case filePlanReference: FilePlanReference => + objectReader.readValue(filePlanReference.getFile, classOf[ExecNodeGraph]) + case contentPlanReference: ContentPlanReference => + objectReader.readValue(contentPlanReference.getContent, classOf[ExecNodeGraph]) + case resourcePlanReference: ResourcePlanReference => { + val url = resourcePlanReference.getClassLoader + .getResource(resourcePlanReference.getResourcePath) + if (url == null) { + throw new IOException( + "Cannot load the plan reference from classpath: " + planReference); + } + objectReader.readValue(new File(url.toURI), classOf[ExecNodeGraph]) + } + case _ => throw new IllegalStateException( + "Unknown PlanReference. This is a bug, please contact the developers") + } + + new ExecNodeGraphCompiledPlan( + this, + JsonSerdeUtil.createObjectWriter(createSerdeContext) + .withDefaultPrettyPrinter() + .writeValueAsString(execNodeGraph), + execNodeGraph) + } + override def compilePlan(modifyOperations: util.List[ModifyOperation]): CompiledPlanInternal = { validateAndOverrideConfiguration() val relNodes = modifyOperations.map(translateToRel) val optimizedRelNodes = optimize(relNodes) val execGraph = translateToExecNodeGraph(optimizedRelNodes) cleanupInternalConfigurations() - new ExecNodeGraphCompiledPlan(createSerdeContext, execGraph) + new ExecNodeGraphCompiledPlan( + this, + JsonSerdeUtil.createObjectWriter(createSerdeContext) + .withDefaultPrettyPrinter() Review comment: When writing to a file, i don't think it's a big deal for the user. I would actually prefer to write out pretty printed plan always, so they can be easily debugged without much hassle of going through a json beautifier -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org