Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](tvf) fix FE cannot start when replay alter view from tvf (#40872) #41159

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,12 @@ public void replayModifyViewDef(AlterViewInfo alterViewInfo) throws MetaNotFound
try {
String viewName = view.getName();
view.setInlineViewDefWithSqlMode(inlineViewDef, alterViewInfo.getSqlMode());
try {
view.init();
} catch (UserException e) {
throw new DdlException("failed to init view stmt, reason=" + e.getMessage());
}
view.setNewFullSchema(newFullSchema);

// We do not need to init view here.
// During the `init` phase, some `Alter-View` statements will access the remote file system,
// but they should not access it during the metadata replay phase.

db.dropTable(viewName);
db.createTable(view);

Expand Down
44 changes: 44 additions & 0 deletions regression-test/data/external_table_p0/tvf/test_hdfs_tvf.out
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,47 @@ string_col text Yes false \N NONE
string_col text Yes false \N NONE
tinyint_col tinyint Yes false \N NONE

-- !create_view --
0 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
1 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
10 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
100 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
101 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
102 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
103 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
104 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
105 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
106 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
107 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
108 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
109 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
11 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
110 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
111 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
112 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
113 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
114 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59
115 2 3 4 5 6.6 7.7 8.8 abc def ghiaaaaaa 2020-10-10 2020-10-10 11:12:59

-- !alter_view --
0
1
10
100
101
102
103
104
105
106
107
108
109
11
110
111
112
113
114
115

26 changes: 26 additions & 0 deletions regression-test/suites/external_table_p0/tvf/test_hdfs_tvf.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,32 @@ suite("test_hdfs_tvf","external,hive,tvf,external_docker") {
"column_separator" = ",",
"format" = "${format}"); """


// test create view from tvf and alter view from tvf
uri = "${defaultFS}" + "/user/doris/preinstalled_data/csv_format_test/all_types.csv"
format = "csv"
sql """ DROP VIEW IF EXISTS test_hdfs_tvf_create_view;"""
sql """
create view test_hdfs_tvf_create_view as
select * from HDFS(
"uri" = "${uri}",
"hadoop.username" = "${hdfsUserName}",
"column_separator" = ",",
"format" = "${format}") order by c1;
"""

order_qt_create_view """ select * from test_hdfs_tvf_create_view order by c1 limit 20; """

sql """
alter view test_hdfs_tvf_create_view as
select c1 from HDFS(
"uri" = "${uri}",
"hadoop.username" = "${hdfsUserName}",
"column_separator" = ",",
"format" = "${format}") order by c1;
"""

order_qt_alter_view """ select * from test_hdfs_tvf_create_view order by c1 limit 20; """
} finally {
}
}
Expand Down
Loading