[
https://issues.apache.org/jira/browse/FLINK-19649?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
gsralex updated FLINK-19649:
----------------------------
Description:
In Flink's module flink-sql-parser, the sqlCreateTable.class unparse method
The create table statement does not match the new rules of the print connector.
The print connector supports this:
{code:java}
CREATE TABLE table_print WITH ('connector' = 'print') LIKE table (EXCLUDING
ALL){code}
When a print table is created without any columns, the parentheses must be
omitted.
However, the unparse generated statements in SqlCreateTable contain
parentheses. This will affect the SqlCreateTable.toString()
,SqlCreateTable.toSqlString() methods.
{code:java}
CREATE TABLE table_print() WITH ('connector' = 'print') LIKE table (EXCLUDING
ALL)
{code}
Might need to add the following to the unparse method for columnList.size > 0.
{code:java}
if (columnList.size() > 0) {
SqlWriter.Frame frame =
writer.startList(SqlWriter.FrameTypeEnum.create("sds"), "(", ")");
for (SqlNode column : columnList) {
printIndent(writer);
if (column instanceof SqlBasicCall) {
SqlCall call = (SqlCall) column;
SqlCall newCall = call.getOperator().createCall(
SqlParserPos.ZERO,
call.operand(1),
call.operand(0));
newCall.unparse(writer, leftPrec, rightPrec);
} else {
column.unparse(writer, leftPrec, rightPrec);
}
}
if (tableConstraints.size() > 0) {
for (SqlTableConstraint constraint : tableConstraints) {
printIndent(writer);
constraint.unparse(writer, leftPrec, rightPrec);
}
}
if (watermark != null) {
printIndent(writer);
watermark.unparse(writer, leftPrec, rightPrec);
}
writer.newlineAndIndent();
writer.endList(frame);
}
{code}
My English isn't very good. I hope I've made myself clear. Thanks.
was:
In Flink's module flink-sql-parser, the sqlCreateTable.class unparse method
The create table statement does not match the new rules of the print connector.
The print connector supports this:
{code:java}
CREATE TABLE table_print WITH ('connector' = 'print') LIKE table (EXCLUDING
ALL){code}
When a print table is created without any columns, the parentheses must be
omitted.
However, the unparse generated statements in SqlCreateTable contain
parentheses. This will affect the SqlCreateTable.toString()
,SqlCreateTable.toSqlString() methods.
Might need to add the following to the unparse method for columnList.size > 0.
{code:java}
if (columnList.size() > 0) {
SqlWriter.Frame frame =
writer.startList(SqlWriter.FrameTypeEnum.create("sds"), "(", ")");
for (SqlNode column : columnList) {
printIndent(writer);
if (column instanceof SqlBasicCall) {
SqlCall call = (SqlCall) column;
SqlCall newCall = call.getOperator().createCall(
SqlParserPos.ZERO,
call.operand(1),
call.operand(0));
newCall.unparse(writer, leftPrec, rightPrec);
} else {
column.unparse(writer, leftPrec, rightPrec);
}
}
if (tableConstraints.size() > 0) {
for (SqlTableConstraint constraint : tableConstraints) {
printIndent(writer);
constraint.unparse(writer, leftPrec, rightPrec);
}
}
if (watermark != null) {
printIndent(writer);
watermark.unparse(writer, leftPrec, rightPrec);
}
writer.newlineAndIndent();
writer.endList(frame);
}
{code}
My English isn't very good. I hope I've made myself clear. Thanks.
> In Flink's module flink-sql-parser/sqlCreateTable/unparse, the tables
> without columns are not supported.
> ---------------------------------------------------------------------------------------------------------
>
> Key: FLINK-19649
> URL: https://issues.apache.org/jira/browse/FLINK-19649
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / API
> Affects Versions: 1.11.2
> Reporter: gsralex
> Priority: Minor
>
> In Flink's module flink-sql-parser, the sqlCreateTable.class unparse method
> The create table statement does not match the new rules of the print
> connector.
> The print connector supports this:
> {code:java}
> CREATE TABLE table_print WITH ('connector' = 'print') LIKE table (EXCLUDING
> ALL){code}
> When a print table is created without any columns, the parentheses must be
> omitted.
> However, the unparse generated statements in SqlCreateTable contain
> parentheses. This will affect the SqlCreateTable.toString()
> ,SqlCreateTable.toSqlString() methods.
> {code:java}
> CREATE TABLE table_print() WITH ('connector' = 'print') LIKE table (EXCLUDING
> ALL)
> {code}
> Might need to add the following to the unparse method for columnList.size > 0.
>
> {code:java}
> if (columnList.size() > 0) {
> SqlWriter.Frame frame =
> writer.startList(SqlWriter.FrameTypeEnum.create("sds"), "(", ")");
> for (SqlNode column : columnList) {
> printIndent(writer);
> if (column instanceof SqlBasicCall) {
> SqlCall call = (SqlCall) column;
> SqlCall newCall = call.getOperator().createCall(
> SqlParserPos.ZERO,
> call.operand(1),
> call.operand(0));
> newCall.unparse(writer, leftPrec, rightPrec);
> } else {
> column.unparse(writer, leftPrec, rightPrec);
> }
> }
> if (tableConstraints.size() > 0) {
> for (SqlTableConstraint constraint : tableConstraints) {
> printIndent(writer);
> constraint.unparse(writer, leftPrec, rightPrec);
> }
> }
> if (watermark != null) {
> printIndent(writer);
> watermark.unparse(writer, leftPrec, rightPrec);
> }
> writer.newlineAndIndent();
> writer.endList(frame);
> }
> {code}
>
> My English isn't very good. I hope I've made myself clear. Thanks.
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)