twalthr commented on code in PR #27256: URL: https://github.com/apache/flink/pull/27256#discussion_r2549250391
########## flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlDropObject.java: ########## @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.sql.parser.ddl; + +import org.apache.calcite.sql.SqlDrop; +import org.apache.calcite.sql.SqlIdentifier; +import org.apache.calcite.sql.SqlNode; +import org.apache.calcite.sql.SqlOperator; +import org.apache.calcite.sql.parser.SqlParserPos; +import org.apache.calcite.util.ImmutableNullableList; + +import java.util.List; + +/** Base class for DROP DDL sql calls. */ Review Comment: ```suggestion /** Base class for DROP DDL SQL calls. */ ``` ########## flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/SqlNodeToOperationConversion.java: ########## @@ -579,22 +578,18 @@ private Operation convertCreateDatabase(SqlCreateDatabase sqlCreateDatabase) { String databaseName = (fullDatabaseName.length == 1) ? fullDatabaseName[0] : fullDatabaseName[1]; boolean ignoreIfExists = sqlCreateDatabase.isIfNotExists(); - String databaseComment = - sqlCreateDatabase - .getComment() - .map(comment -> comment.getValueAs(NlsString.class).getValue()) - .orElse(null); + String databaseComment = OperationConverterUtils.getComment(sqlCreateDatabase.getComment()); // set with properties final Map<String, String> properties = - OperationConverterUtils.getProperties(sqlCreateDatabase.getPropertyList()); + OperationConverterUtils.getProperties(sqlCreateDatabase.getProperties()); Review Comment: also here let's return a Map<String, String> from the parser. We shouldn't expose parser internals to the caller. ```suggestion sqlCreateDatabase.getProperties(); ``` ########## flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/SqlNodeToOperationConversion.java: ########## @@ -579,22 +578,18 @@ private Operation convertCreateDatabase(SqlCreateDatabase sqlCreateDatabase) { String databaseName = (fullDatabaseName.length == 1) ? fullDatabaseName[0] : fullDatabaseName[1]; boolean ignoreIfExists = sqlCreateDatabase.isIfNotExists(); - String databaseComment = - sqlCreateDatabase - .getComment() - .map(comment -> comment.getValueAs(NlsString.class).getValue()) - .orElse(null); + String databaseComment = OperationConverterUtils.getComment(sqlCreateDatabase.getComment()); Review Comment: following my comment above: ```suggestion String databaseComment = sqlCreateDatabase.getComment(); ``` ########## flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlDistribution.java: ########## @@ -51,18 +50,13 @@ public SqlDistribution( SqlParserPos pos, @Nullable String distributionKind, @Nullable SqlNodeList bucketColumns, - @Nullable SqlNumericLiteral bucketCount) { - super(pos); + SqlNumericLiteral bucketCount) { Review Comment: why not nullable anymore? ########## flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlAlterModelRename.java: ########## @@ -51,12 +51,12 @@ public String[] fullNewModelName() { @Override public List<SqlNode> getOperandList() { - return List.of(modelName, newModelName); + return List.of(getName(), newModelName); Review Comment: nit: we could also just use protected for `name` then `getName` could return String or will simply not be needed anymore. ########## flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlAlterCatalogReset.java: ########## @@ -62,15 +62,8 @@ public Set<String> getResetKeys() { } @Override - public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { - super.unparse(writer, leftPrec, rightPrec); - writer.keyword("RESET"); - SqlWriter.Frame withFrame = writer.startList("(", ")"); - for (SqlNode property : propertyKeyList) { - SqlUnparseUtils.printIndent(writer); - property.unparse(writer, leftPrec, rightPrec); - } - writer.newlineAndIndent(); - writer.endList(withFrame); + public void unparseAlterOperation(SqlWriter writer, int leftPrec, int rightPrec) { + super.unparseAlterOperation(writer, leftPrec, rightPrec); + SqlUnparseUtils.unparseResetProperties(propertyKeyList, writer, leftPrec, rightPrec); Review Comment: ```suggestion SqlUnparseUtils.unparseResetOptions(propertyKeyList, writer, leftPrec, rightPrec); ``` ########## flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlAlterCatalogComment.java: ########## @@ -31,27 +34,26 @@ /** ALTER CATALOG catalog_name COMMENT 'comment'. */ public class SqlAlterCatalogComment extends SqlAlterCatalog { - private final SqlNode comment; + private final SqlCharStringLiteral comment; public SqlAlterCatalogComment( - SqlParserPos position, SqlIdentifier catalogName, SqlNode comment) { + SqlParserPos position, SqlIdentifier catalogName, SqlCharStringLiteral comment) { super(position, catalogName); this.comment = requireNonNull(comment, "comment cannot be null"); } @Override public List<SqlNode> getOperandList() { - return ImmutableNullableList.of(catalogName, comment); + return ImmutableNullableList.of(getName(), comment); } - public SqlNode getComment() { + public SqlCharStringLiteral getComment() { Review Comment: Can't we just return string already? No outside consumer really needs `SqlCharStringLiteral` anymore right? -- 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]
