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](Nereids) fix fold constant of time acquired functions #47288

Merged
merged 1 commit into from
Jan 22, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -2387,37 +2387,37 @@ public Expression visitArithmeticBinary(ArithmeticBinaryContext ctx) {

@Override
public Expression visitCurrentDate(DorisParser.CurrentDateContext ctx) {
return new CurrentDate().alias("CURRENT_DATE");
return new CurrentDate();
}

@Override
public Expression visitCurrentTime(DorisParser.CurrentTimeContext ctx) {
return new CurrentTime().alias("CURRENT_TIME");
return new CurrentTime();
}

@Override
public Expression visitCurrentTimestamp(DorisParser.CurrentTimestampContext ctx) {
return new Now().alias("CURRENT_TIMESTAMP");
return new Now();
}

@Override
public Expression visitLocalTime(DorisParser.LocalTimeContext ctx) {
return new CurrentTime().alias("LOCALTIME");
return new CurrentTime();
}

@Override
public Expression visitLocalTimestamp(DorisParser.LocalTimestampContext ctx) {
return new Now().alias("LOCALTIMESTAMP");
return new Now();
}

@Override
public Expression visitCurrentUser(DorisParser.CurrentUserContext ctx) {
return new CurrentUser().alias("CURRENT_USER");
return new CurrentUser();
}

@Override
public Expression visitSessionUser(DorisParser.SessionUserContext ctx) {
return new SessionUser().alias("SESSION_USER");
return new SessionUser();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

suite("fold_constant_date_arithmatic") {
def db = "fold_constant_date_arithmatic"
sql "create database if not exists ${db}"

sql "set enable_nereids_planner=true"
sql "set enable_fallback_to_original_planner=false"
sql "set enable_fold_constant_by_be=false"

testFoldConst("select substr(now(), 1, 10);")
testFoldConst("select substr(now(3), 1, 10);")
testFoldConst("select substr(curdate(), 1, 10);")
testFoldConst("select substr(current_date(), 1, 10);")
testFoldConst("select substr(current_timestamp(), 1, 10);")
testFoldConst("select substr(current_timestamp(3), 1, 10);")
}
Loading