Skip to content

Commit

Permalink
IGNITE-23523 Sql. Fixed incorrect time formatting in sql logic tests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ygerzhedovich authored Nov 7, 2024
1 parent 5ce4d3f commit 9bf6248
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 325 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
Expand All @@ -32,6 +35,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.calcite.avatica.util.ByteString;
import org.apache.ignite.internal.sql.engine.util.SqlTestUtils;
import org.apache.ignite.internal.util.CollectionUtils;
import org.apache.ignite.internal.util.StringUtils;

Expand Down Expand Up @@ -451,6 +455,10 @@ private static String resultToString(ScriptContext ctx, Object res) {
return ByteString.toString((byte[]) res, 16);
} else if (res instanceof Map) {
return mapToString(ctx, (Map<?, ?>) res);
} else if (res instanceof LocalTime) {
return ((LocalTime) res).format(DateTimeFormatter.ISO_TIME);
} else if (res instanceof LocalDateTime) {
return ((LocalDateTime) res).format(SqlTestUtils.SQL_CONFORMANT_DATETIME_FORMATTER);
} else {
return String.valueOf(res);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,56 +24,94 @@ SELECT SUM(1), SUM(NULL), SUM(33.3)
NULL
33.300000

statement error
statement error: Cannot apply 'SUM' to arguments of type 'SUM(<BOOLEAN>)'. Supported form(s): 'SUM(<NUMERIC>)'
SELECT SUM(True)

statement error
statement error: Cannot apply 'SUM' to arguments of type 'SUM(<CHAR(5)>)'. Supported form(s): 'SUM(<NUMERIC>)'
SELECT SUM('hello')

statement error
statement error: Cannot apply 'SUM' to arguments of type 'SUM(<DATE>)'. Supported form(s): 'SUM(<NUMERIC>)'
SELECT SUM(DATE '1992-02-02')

statement error
statement error: Invalid number of arguments to function 'SUM'. Was expecting 1 arguments
SELECT SUM()

statement error
statement error: Invalid number of arguments to function 'SUM'. Was expecting 1 arguments
SELECT SUM(1, 2)

statement error
query IIRTTTT
SELECT MIN(1), MIN(NULL), MIN(33.3), MIN('hello'), MIN(True), MIN(DATE '1992-02-02'), MIN(TIMESTAMP '2008-01-01 00:00:01')
----
1 NULL 33.300000 hello true 1992-02-02 2008-01-01 00:00:01

statement error: Invalid number of arguments to function 'MIN'. Was expecting 1 arguments
SELECT MIN()

statement error
statement error: Invalid number of arguments to function 'MIN'. Was expecting 1 arguments
SELECT MIN(1, 2)

statement error
query IIRTTTT
SELECT MAX(1), MAX(NULL), MAX(33.3), MAX('hello'), MAX(True), MAX(DATE '1992-02-02'), MAX(TIMESTAMP '2008-01-01 00:00:01')
----
1 NULL 33.300000 hello true 1992-02-02 2008-01-01 00:00:01

statement error: Invalid number of arguments to function 'MAX'. Was expecting 1 arguments
SELECT MAX()

statement error
statement error: Invalid number of arguments to function 'MAX'. Was expecting 1 arguments
SELECT MAX(1, 2)

statement error
query IIRTTTT
SELECT ANY_VALUE(1), ANY_VALUE(NULL), ANY_VALUE(33.3), ANY_VALUE('hello'), ANY_VALUE(True), ANY_VALUE(DATE '1992-02-02'), ANY_VALUE(TIMESTAMP '2008-01-01 00:00:01')
----
1 NULL 33.300000 hello true 1992-02-02 2008-01-01 00:00:01

statement error: Invalid number of arguments to function 'ANY_VALUE'. Was expecting 1 arguments
SELECT ANY_VALUE()

statement error
statement error: Invalid number of arguments to function 'ANY_VALUE'. Was expecting 1 arguments
SELECT ANY_VALUE(1, 2)

query RRR
SELECT AVG(1), AVG(NULL), AVG(33.3)
----
1.000000 NULL 33.300000

statement error
statement error: Cannot apply 'AVG' to arguments of type 'AVG(<BOOLEAN>)'. Supported form(s): 'AVG(<NUMERIC>)'
SELECT AVG(True)

statement error
statement error: Cannot apply 'AVG' to arguments of type 'AVG(<CHAR(5)>)'. Supported form(s): 'AVG(<NUMERIC>)'
SELECT AVG('hello')

statement error
statement error: Cannot apply 'AVG' to arguments of type 'AVG(<DATE>)'. Supported form(s): 'AVG(<NUMERIC>)'
SELECT AVG(DATE '1992-02-02')

statement error
statement error: Invalid number of arguments to function 'AVG'. Was expecting 1 arguments
SELECT AVG()

statement error
statement error: Invalid number of arguments to function 'AVG'. Was expecting 1 arguments
SELECT AVG(1, 2)

skipif ignite3
# https://issues.apache.org/jira/browse/IGNITE-19333
query T
SELECT STRING_AGG('hello')
----
hello

skipif ignite3
# https://issues.apache.org/jira/browse/IGNITE-19333
query TTTTT
SELECT STRING_AGG('hello', ' '), STRING_AGG('hello', NULL), STRING_AGG(NULL, ' '), STRING_AGG(NULL, NULL), STRING_AGG('', '')
----
hello hello NULL NULL (empty)

skipif ignite3
# https://issues.apache.org/jira/browse/IGNITE-19333
statement error: some error text
SELECT STRING_AGG()

skipif ignite3
# https://issues.apache.org/jira/browse/IGNITE-19333
statement error: some error text
SELECT STRING_AGG(1, 2, 3)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ SELECT cast('JUN 30, 2018' as date format 'MON DD, YYYY')
query T
SELECT cast('17:30' as time format 'HH12:MI')
----
17:30
17:30:00

query T
SELECT cast('01:05:07.161' as time format 'HH24:MI:SS.FF4')
Expand All @@ -180,12 +180,12 @@ SELECT cast('01:05:07.161' as time format 'HH24:MI:SS.FF4')
query T
SELECT cast('2017-05-12' as timestamp format 'YYYY-MM-DD')
----
2017-05-12T00:00
2017-05-12 00:00:00

query T
SELECT cast('2020.06.03 12:42:53' as timestamp format 'YYYY.MM.DD HH:MI:SS')
----
2020-06-03T12:42:53
2020-06-03 12:42:53

# Seems will be supported after resolve CALCITE_6367
statement error: Invalid format: 'YYYY.MM.DD HH24:MI:SSTZH:TZM' for datetime string: '2020.06.03 00:00:53+06:30'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
query T
SELECT CAST('1992-01-01 10:11:12' AS TIMESTAMP);
----
1992-01-01T10:11:12
1992-01-01 10:11:12

query T
SELECT CAST('1992-01-01 10:11:12'::TIMESTAMP AS TIMESTAMP);
----
1992-01-01T10:11:12
1992-01-01 10:11:12

query T
SELECT CAST('1992-01-01 10:11:12'::VARCHAR AS TIMESTAMP);
----
1992-01-01T10:11:12
1992-01-01 10:11:12

query T
SELECT CAST('1992-01-01 10:11:12'::CHAR(19) AS TIMESTAMP);
----
1992-01-01T10:11:12
1992-01-01 10:11:12

# Current Date + time
statement ok
Expand All @@ -30,7 +30,7 @@ SELECT CAST('10:11:12'::TIME AS TIMESTAMP);
query T
SELECT CAST('1992-01-01'::DATE AS TIMESTAMP);
----
1992-01-01T00:00
1992-01-01 00:00:00

statement error: Cast function cannot convert value of type BOOLEAN to type TIMESTAMP(6)
SELECT CAST(TRUE AS TIMESTAMP);
Expand Down
Loading

0 comments on commit 9bf6248

Please sign in to comment.