jnh5y commented on code in PR #25064: URL: https://github.com/apache/flink/pull/25064#discussion_r1672433347
########## flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/delegation/PlannerBase.scala: ########## @@ -182,6 +186,58 @@ abstract class PlannerBase( transformations } + override def loadPlan(planReference: PlanReference): InternalPlan = { + 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 ExecNodeGraphInternalPlan( + // ensures that the JSON output is always normalized + () => + JsonSerdeUtil + .createObjectWriter(ctx) + .withDefaultPrettyPrinter() + .writeValueAsString(execNodeGraph), + execNodeGraph) + } Review Comment: This bit is just refactoring that moves https://github.com/apache/flink/blob/master/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/delegation/StreamPlanner.scala#L192-L215 to PlannerBase. Should we refactor it as we move it? Or do that separately? -- 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