Skip to content

Commit

Permalink
[fix](view) The parameter positions of timestamp diff function to sql…
Browse files Browse the repository at this point in the history
… are reversed (#23601)
  • Loading branch information
morrySnow authored and xiaokang committed Aug 29, 2023
1 parent 8c49884 commit 89736fe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ private String paramsToSql() {
|| fnName.getFunction().equalsIgnoreCase("hours_diff")
|| fnName.getFunction().equalsIgnoreCase("minutes_diff")
|| fnName.getFunction().equalsIgnoreCase("seconds_diff")) {
sb.append(children.get(1).toSql()).append(", ");
sb.append(children.get(0).toSql()).append(")");
sb.append(children.get(0).toSql()).append(", ");
sb.append(children.get(1).toSql()).append(")");
return sb.toString();
}
// used by nereids END
Expand Down
3 changes: 3 additions & 0 deletions regression-test/data/view_p0/view_p0.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
1 2023-08-01 DORID_FIELD1 DORID_FIELD2 ["cat", "dog"] cat
1 2023-08-01 DORID_FIELD1 DORID_FIELD2 ["cat", "dog"] dog

-- !sql --
960

10 changes: 10 additions & 0 deletions regression-test/suites/view_p0/view_p0.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,15 @@ suite("view_p0") {
) c;
"""
qt_sql "select * from test_element_at_view;"

sql "drop view if exists test_element_at_view"

sql "drop view if exists test_time_diff"

sql "create view test_time_diff as select minutes_diff('2023-01-16 10:05:04', '2023-01-15 18:05:04')"

qt_sql "select * from test_time_diff"

sql "drop view if exists test_time_diff"

}

0 comments on commit 89736fe

Please sign in to comment.