raminqaf commented on code in PR #28510:
URL: https://github.com/apache/flink/pull/28510#discussion_r3457689792
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlNodeConvertUtils.java:
##########
@@ -108,6 +112,30 @@ static PlannerQueryOperation toQueryOperation(SqlNode
validated, ConvertContext
relational.project(), () ->
context.toQuotedSqlString(validated));
}
+ /**
+ * Validates the given materialized table {@code AS} query and converts it
into a {@link
+ * PlannerQueryOperation}. Shared by the CREATE / CREATE OR ALTER / ALTER
... AS converters.
+ */
+ public static PlannerQueryOperation validateAndConvertAsQuery(
+ SqlNode asQuery, ConvertContext context) {
+ final FlinkPlannerImpl flinkPlanner = context.getFlinkPlanner();
+ final SqlNode validated = flinkPlanner.validate(asQuery);
+ final Operation operation =
+ SqlNodeToOperationConversion.convert(
+ flinkPlanner, context.getCatalogManager(),
validated)
+ .orElseThrow(
+ () ->
+ new TableException(
Review Comment:
I will make it more generic. We can even replace the AsQuery validation of
RTAS and CTAS with this method. Should I do it in this PR as a separate commit
or leave the code there untouched?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]