This is an automated email from the ASF dual-hosted git repository. xxyu pushed a commit to branch kylin5 in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 6855e40fafbafd25b2048cc2698ad22d8d2b3d51 Author: liang.huang <83992752+lhuang09287...@users.noreply.github.com> AuthorDate: Sat Jun 10 09:24:46 2023 +0800 KYLIN-5721 make data_trunc support date string args and give tests to second,miniute,hour,extract funcs for date string args * KYLIN-5721 make data_trunc support date string args and add test cases for second,miniute,hour,extract for date string args --- .../sql_computedcolumn_DateUDF/query05.sql | 39 ++++++++++++++++++++++ .../sql_function/sql_function_DateUDF/query07.sql | 29 ++++++++++++++++ .../kylin/query/udf/dateUdf/DateTruncUDF.java | 5 +++ 3 files changed, 73 insertions(+) diff --git a/src/kylin-it/src/test/resources/query/sql_computedcolumn/sql_computedcolumn_DateUDF/query05.sql b/src/kylin-it/src/test/resources/query/sql_computedcolumn/sql_computedcolumn_DateUDF/query05.sql new file mode 100644 index 0000000000..4e2a5e1d74 --- /dev/null +++ b/src/kylin-it/src/test/resources/query/sql_computedcolumn/sql_computedcolumn_DateUDF/query05.sql @@ -0,0 +1,39 @@ +-- +-- 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. +-- + +select + count(DATE_TRUNC('YEAR', cast("CAL_DT" as string))), + count(DATE_TRUNC('YYYY', cast("CAL_DT" as string))), + count(DATE_TRUNC('YY', cast("CAL_DT" as string))), + count(DATE_TRUNC('MM', cast("CAL_DT" as string))), + count(DATE_TRUNC('MONTH', cast("CAL_DT" as string))), + count(DATE_TRUNC('DAY', cast("CAL_DT" as string))), + count(DATE_TRUNC('DD', cast("CAL_DT" as string))), + count(DATE_TRUNC('HOUR', cast("CAL_DT" as string))), + count(DATE_TRUNC('WEEK', cast("CAL_DT" as string))), + + count(distinct DATE_TRUNC('YEAR', cast("CAL_DT" as string))), + count(distinct DATE_TRUNC('YYYY', cast("CAL_DT" as string))), + count(distinct DATE_TRUNC('YY', cast("CAL_DT" as string))), + count(distinct DATE_TRUNC('MM', cast("CAL_DT" as string))), + count(distinct DATE_TRUNC('MONTH', cast("CAL_DT" as string))), + count(distinct DATE_TRUNC('DAY', cast("CAL_DT" as string))), + count(distinct DATE_TRUNC('DD', cast("CAL_DT" as string))), + count(distinct DATE_TRUNC('HOUR', cast("CAL_DT" as string))), + count(distinct DATE_TRUNC('WEEK', cast("CAL_DT" as string))) +from TEST_KYLIN_FACT diff --git a/src/kylin-it/src/test/resources/query/sql_function/sql_function_DateUDF/query07.sql b/src/kylin-it/src/test/resources/query/sql_function/sql_function_DateUDF/query07.sql new file mode 100644 index 0000000000..69f55516fe --- /dev/null +++ b/src/kylin-it/src/test/resources/query/sql_function/sql_function_DateUDF/query07.sql @@ -0,0 +1,29 @@ +-- +-- 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. +-- + +select + DATE_TRUNC('YEAR', cast("CAL_DT" as string)), + DATE_TRUNC('YYYY', cast("CAL_DT" as string)), + DATE_TRUNC('YY', cast("CAL_DT" as string)), + DATE_TRUNC('MM', cast("CAL_DT" as string)), + DATE_TRUNC('MONTH', cast("CAL_DT" as string)), + DATE_TRUNC('DAY', cast("CAL_DT" as string)), + DATE_TRUNC('DD', cast("CAL_DT" as string)), + DATE_TRUNC('HOUR', cast("CAL_DT" as string)), + DATE_TRUNC('WEEK', cast("CAL_DT" as string)) +from TEST_KYLIN_FACT diff --git a/src/query/src/main/java/org/apache/kylin/query/udf/dateUdf/DateTruncUDF.java b/src/query/src/main/java/org/apache/kylin/query/udf/dateUdf/DateTruncUDF.java index 06c258c4f4..df80b15241 100644 --- a/src/query/src/main/java/org/apache/kylin/query/udf/dateUdf/DateTruncUDF.java +++ b/src/query/src/main/java/org/apache/kylin/query/udf/dateUdf/DateTruncUDF.java @@ -36,4 +36,9 @@ public class DateTruncUDF implements NotConstant { throws CalciteNotSupportException { throw new CalciteNotSupportException(); } + + public Date DATE_TRUNC(@Parameter(name = "part") String part, @Parameter(name = "date") String date) + throws CalciteNotSupportException { + throw new CalciteNotSupportException(); + } } \ No newline at end of file