Mingcan Wang created FLINK-37121: ------------------------------------ Summary: Fix syntax and examples in create table statement doc Key: FLINK-37121 URL: https://issues.apache.org/jira/browse/FLINK-37121 Project: Flink Issue Type: Improvement Components: Documentation Affects Versions: 2.0-preview, 1.20.0 Environment: mac os Reporter: Mingcan Wang Fix For: 2.0-preview, 1.20.0
create table in parserImpls.ftl : *DISTRIBUTION* clause is before *PARTITION* clause. {code:java} SqlCreate SqlCreateTable(Span s, boolean replace, boolean isTemporary) : { final SqlParserPos startPos = s.pos(); boolean ifNotExists = false; SqlIdentifier tableName; List<SqlTableConstraint> constraints = new ArrayList<SqlTableConstraint>(); SqlWatermark watermark = null; SqlNodeList columnList = SqlNodeList.EMPTY; SqlCharStringLiteral comment = null; SqlTableLike tableLike = null; SqlNode asQuery = null; SqlNodeList propertyList = SqlNodeList.EMPTY; SqlDistribution distribution = null; SqlNodeList partitionColumns = SqlNodeList.EMPTY; SqlParserPos pos = startPos; boolean isColumnsIdentifiersOnly = false; } { <TABLE> ifNotExists = IfNotExistsOpt() tableName = CompoundIdentifier() [ <LPAREN> { pos = getPos(); TableCreationContext ctx = new TableCreationContext();} TableColumnsOrIdentifiers(pos, ctx) { pos = pos.plus(getPos()); isColumnsIdentifiersOnly = ctx.isColumnsIdentifiersOnly(); columnList = new SqlNodeList(ctx.columnList, pos); constraints = ctx.constraints; watermark = ctx.watermark; } <RPAREN> ] [ <COMMENT> <QUOTED_STRING> { String p = SqlParserUtil.parseString(token.image); comment = SqlLiteral.createCharString(p, getPos()); }] [ <DISTRIBUTED> distribution = SqlDistribution(getPos()) ] [ <PARTITIONED> <BY> partitionColumns = ParenthesizedSimpleIdentifierList() ] [ <WITH> propertyList = Properties() ] [ <LIKE> tableLike = SqlTableLike(getPos()) { if (isColumnsIdentifiersOnly) { throw SqlUtil.newContextException( pos, ParserResource.RESOURCE.columnsIdentifiersUnsupported()); } return new SqlCreateTableLike(startPos.plus(getPos()), tableName, columnList, constraints, propertyList, distribution, partitionColumns, watermark, comment, tableLike, isTemporary, ifNotExists); } | <AS> asQuery = OrderedQueryOrExpr(ExprContext.ACCEPT_QUERY) { if (replace) { return new SqlReplaceTableAs(startPos.plus(getPos()), tableName, columnList, constraints, propertyList, distribution, partitionColumns, watermark, comment, asQuery, isTemporary, ifNotExists, true); } else { return new SqlCreateTableAs(startPos.plus(getPos()), tableName, columnList, constraints, propertyList, distribution, partitionColumns, watermark, comment, asQuery, isTemporary, ifNotExists); } } ] { if (isColumnsIdentifiersOnly) { throw SqlUtil.newContextException( pos, ParserResource.RESOURCE.columnsIdentifiersUnsupported()); } return new SqlCreateTable(startPos.plus(getPos()), tableName, columnList, constraints, propertyList, distribution, partitionColumns, watermark, comment, isTemporary, ifNotExists); } } {code} And I try to parse a sql which *DISTRIBUTION* clause is after *PARTITION* clause will failed.So we need to move the *[ <distribution> ]* before *[PARTITIONED BY]* And the syntax is missing the *TEMPORARY* optional keyword. And some examples have a comma at the end of the last column -- This message was sent by Atlassian Jira (v8.20.10#820010)