This is an automated email from the ASF dual-hosted git repository. alexpl pushed a commit to branch sql-calcite in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/sql-calcite by this push: new b0fc1eb IGNITE-14954 Fix MONTHNAME, DAYNAME functions fail - Fixes #9311. b0fc1eb is described below commit b0fc1ebf9e1c0b0093e74b4fb5c4d9ba1af08229 Author: Aleksey Plekhanov <plehanov.a...@gmail.com> AuthorDate: Fri Aug 20 16:36:53 2021 +0300 IGNITE-14954 Fix MONTHNAME, DAYNAME functions fail - Fixes #9311. Signed-off-by: Aleksey Plekhanov <plehanov.a...@gmail.com> --- .../processors/query/calcite/exec/ExecutionContext.java | 7 +++++++ .../internal/processors/query/calcite/FunctionsTest.java | 7 +++++++ .../src/test/sql/function/date/test_date_part.test | 16 ++++++++++++++++ .../test/sql/function/date/test_date_part.test_ignore | 5 ++--- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionContext.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionContext.java index 0417571..4ddebc4 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionContext.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionContext.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.query.calcite.exec; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.TimeZone; import java.util.UUID; @@ -51,6 +52,10 @@ public class ExecutionContext<Row> implements DataContext { private static final TimeZone TIME_ZONE = TimeZone.getDefault(); // TODO DistributedSqlConfiguration#timeZone /** */ + // TODO https://issues.apache.org/jira/browse/IGNITE-15276 Support other locales. + private static final Locale LOCALE = Locale.ENGLISH; + + /** */ private final UUID qryId; /** */ @@ -209,6 +214,8 @@ public class ExecutionContext<Row> implements DataContext { return startTs; if (Variable.LOCAL_TIMESTAMP.camelName.equals(name)) return startTs; + if (Variable.LOCALE.camelName.equals(name)) + return LOCALE; if (name.startsWith("?")) return TypeUtils.toInternal(this, params.get(name)); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/FunctionsTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/FunctionsTest.java index 11c80d1..eb9c601 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/FunctionsTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/FunctionsTest.java @@ -225,6 +225,13 @@ public class FunctionsTest extends GridCommonAbstractTest { } /** */ + @Test + public void testMonthnameDayname() { + checkQuery("SELECT MONTHNAME(DATE '2021-01-01')").returns("January").check(); + checkQuery("SELECT DAYNAME(DATE '2021-01-01')").returns("Friday").check(); + } + + /** */ private QueryChecker checkQuery(String qry) { return new QueryChecker(qry) { @Override protected QueryEngine getEngine() { diff --git a/modules/calcite/src/test/sql/function/date/test_date_part.test b/modules/calcite/src/test/sql/function/date/test_date_part.test index f3c067d..aecd9d7 100644 --- a/modules/calcite/src/test/sql/function/date/test_date_part.test +++ b/modules/calcite/src/test/sql/function/date/test_date_part.test @@ -29,6 +29,22 @@ SELECT LAST_DAY(d::timestamp) FROM dates ORDER BY d; 1992-03-31 1992-05-31 +# monthname +query T +SELECT MONTHNAME(d) FROM dates ORDER BY d; +---- +January +March +May + +# dayname +query T +SELECT DAYNAME(d) FROM dates ORDER BY d; +---- +Wednesday +Tuesday +Tuesday + # aliases query I SELECT DAYOFMONTH(d) FROM dates ORDER BY d; diff --git a/modules/calcite/src/test/sql/function/date/test_date_part.test_ignore b/modules/calcite/src/test/sql/function/date/test_date_part.test_ignore index 94d1466..9e7b2cd 100644 --- a/modules/calcite/src/test/sql/function/date/test_date_part.test_ignore +++ b/modules/calcite/src/test/sql/function/date/test_date_part.test_ignore @@ -1,7 +1,6 @@ # name: test/sql/function/date/test_date_part.test # description: DATE_PART test # group: [date] -# Ignored: https://issues.apache.org/jira/browse/IGNITE-14954 # Ignored: https://issues.apache.org/jira/browse/IGNITE-14955 statement ok @@ -105,7 +104,7 @@ SELECT LAST_DAY(d::timestamp) FROM dates ORDER BY d; # monthname query T -SELECT MONTHNAME(d) FROM dates; +SELECT MONTHNAME(d) FROM dates ORDER BY d; ---- January March @@ -113,7 +112,7 @@ May # dayname query T -SELECT DAYNAME(d) FROM dates; +SELECT DAYNAME(d) FROM dates ORDER BY d; ---- Wednesday Tuesday