You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Yuan Huang (Jira)" <ji...@apache.org> on 2022/04/29 01:25:00 UTC
[jira] [Updated] (FLINK-27449) The comment is lost when printing table schema
[ https://issues.apache.org/jira/browse/FLINK-27449?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yuan Huang updated FLINK-27449:
--------------------------------
Description:
User reported that the comment was lost when creating a table from datastream and schema.
So this test will fail:
{quote}@Test
public void test() {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);
DataStream<String> dataStream = env.fromElements("Alice", "Bob", "John");
Schema.Builder builder = Schema.newBuilder();
builder.column("f0", DataTypes.of(String.class)).withComment("this is a comment");
Table table = tableEnv.fromDataStream(dataStream, builder.build()).as("user_name");
table.getResolvedSchema();
table.printSchema();
String expected = "(\n `user_name` STRING COMMENT 'this is a comment'\n)";
Assert.assertEquals(expected, table.getResolvedSchema().toString());
}{quote}
```
@Test
public void test()
{ StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env); DataStream<String> dataStream = env.fromElements("Alice", "Bob", "John"); Schema.Builder builder = Schema.newBuilder(); builder.column("f0", DataTypes.of(String.class)).withComment("this is a comment"); Table table = tableEnv.fromDataStream(dataStream, builder.build()).as("user_name"); table.getResolvedSchema(); table.printSchema(); String expected = "(\n `user_name` STRING COMMENT 'this is a comment'\n)"; Assert.assertEquals(expected, table.getResolvedSchema().toString()); }
```
!test_result.png!
Is it a bug or just meets our expectations?
was:
User reported that the comment was lost when printing the table schema.
So this test will fail:
```
@Test
public void test() {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);
DataStream<String> dataStream = env.fromElements("Alice", "Bob", "John");
Schema.Builder builder = Schema.newBuilder();
builder.column("f0", DataTypes.of(String.class)).withComment("this is a comment");
Table table = tableEnv.fromDataStream(dataStream, builder.build()).as("user_name");
table.getResolvedSchema();
table.printSchema();
String expected = "(\n `user_name` STRING COMMENT 'this is a comment'\n)";
Assert.assertEquals(expected, table.getResolvedSchema().toString());
}
```
!test_result.png!
Is it a bug or just meets our expectations?
> The comment is lost when printing table schema
> ----------------------------------------------
>
> Key: FLINK-27449
> URL: https://issues.apache.org/jira/browse/FLINK-27449
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / API
> Affects Versions: 1.14.4
> Reporter: Yuan Huang
> Priority: Critical
> Attachments: test_result.png
>
>
> User reported that the comment was lost when creating a table from datastream and schema.
> So this test will fail:
> {quote}@Test
> public void test() {
> StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
> StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);
> DataStream<String> dataStream = env.fromElements("Alice", "Bob", "John");
> Schema.Builder builder = Schema.newBuilder();
> builder.column("f0", DataTypes.of(String.class)).withComment("this is a comment");
> Table table = tableEnv.fromDataStream(dataStream, builder.build()).as("user_name");
> table.getResolvedSchema();
> table.printSchema();
> String expected = "(\n `user_name` STRING COMMENT 'this is a comment'\n)";
> Assert.assertEquals(expected, table.getResolvedSchema().toString());
> }{quote}
>
> ```
> @Test
> public void test()
> { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env); DataStream<String> dataStream = env.fromElements("Alice", "Bob", "John"); Schema.Builder builder = Schema.newBuilder(); builder.column("f0", DataTypes.of(String.class)).withComment("this is a comment"); Table table = tableEnv.fromDataStream(dataStream, builder.build()).as("user_name"); table.getResolvedSchema(); table.printSchema(); String expected = "(\n `user_name` STRING COMMENT 'this is a comment'\n)"; Assert.assertEquals(expected, table.getResolvedSchema().toString()); }
> ```
>
> !test_result.png!
>
> Is it a bug or just meets our expectations?
>
--
This message was sent by Atlassian Jira
(v8.20.7#820007)