Skip to content

Commit

Permalink
[FLLINK-36862][table] Address 5th Round Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyutian1 committed Jan 7, 2025
1 parent 9f55186 commit 945487a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/data/sql_functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -681,10 +681,10 @@ temporal:
description: Converts a date string string1 with format string2 (by default 'yyyy-MM-dd') to a date.
- sql: TO_TIMESTAMP_LTZ(numeric[, precision])
table: toTimestampLtz(NUMERIC, PRECISION)
description: Converts an epoch seconds or epoch milliseconds to a TIMESTAMP_LTZ, the valid precision is 0 or 3, the 0 represents TO_TIMESTAMP_LTZ(epochSeconds, 0), the 3 represents TO_TIMESTAMP_LTZ(epochMilliseconds, 3). If no precision is provided, the default precision is 3.
description: Converts an epoch seconds or epoch milliseconds to a TIMESTAMP_LTZ, the valid precision is 0 or 3, the 0 represents TO_TIMESTAMP_LTZ(epochSeconds, 0), the 3 represents TO_TIMESTAMP_LTZ(epochMilliseconds, 3). If no precision is provided, the default precision is 3. If any input is null, the function will return null.
- sql: TO_TIMESTAMP_LTZ(string1[, string2[, string3]])
table: toTimestampLtz(STRING1[, STRING2[, STRING3]])
description: Converts a timestamp string string1 with format string2 (by default 'yyyy-MM-dd HH:mm:ss.SSS') to a TIMESTAMP_LTZ in time zone string3. If no time zone is provided, the default time zone is the session time zone.
description: Converts a timestamp string string1 with format string2 (by default 'yyyy-MM-dd HH:mm:ss.SSS') in time zone string3 (by default 'UTC') to a TIMESTAMP_LTZ. If any input is null, the function will return null.
- sql: TO_TIMESTAMP(string1[, string2])
table: toTimestamp(STRING1[, STRING2])
description: "Converts date time string string1 with format string2 (by default: 'yyyy-MM-dd HH:mm:ss') to a timestamp, without time zone."
Expand Down
4 changes: 2 additions & 2 deletions docs/data/sql_functions_zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,10 @@ temporal:
description: 将格式为 string2(默认为 'yyyy-MM-dd')的字符串 string1 转换为日期。
- sql: TO_TIMESTAMP_LTZ(numeric[, precision])
table: toTimestampLtz(NUMERIC, PRECISION)
description: Converts an epoch seconds or epoch milliseconds to a TIMESTAMP_LTZ, the valid precision is 0 or 3, the 0 represents TO_TIMESTAMP_LTZ(epochSeconds, 0), the 3 represents TO_TIMESTAMP_LTZ(epochMilliseconds, 3). If no precision is provided, the default precision is 3.
description: Converts an epoch seconds or epoch milliseconds to a TIMESTAMP_LTZ, the valid precision is 0 or 3, the 0 represents TO_TIMESTAMP_LTZ(epochSeconds, 0), the 3 represents TO_TIMESTAMP_LTZ(epochMilliseconds, 3). If no precision is provided, the default precision is 3. If any input is null, the function will return null.
- sql: TO_TIMESTAMP_LTZ(string1[, string2[, string3]])
table: toTimestampLtz(STRING1[, STRING2[, STRING3]])
description: Converts a timestamp string string1 with format string2 (by default 'yyyy-MM-dd HH:mm:ss.SSS') to a TIMESTAMP_LTZ in time zone string3. If no time zone is provided, the default time zone is the session time zone.
description: Converts a timestamp string string1 with format string2 (by default 'yyyy-MM-dd HH:mm:ss.SSS') in time zone string3 (by default 'UTC') to a TIMESTAMP_LTZ. If any input is null, the function will return null.
- sql: TO_TIMESTAMP(string1[, string2])
table: toTimestamp(STRING1[, STRING2])
description: 将格式为 string2(默认为:'yyyy-MM-dd HH:mm:ss')的字符串 string1 转换为 timestamp,不带时区。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2347,7 +2347,7 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
sequence(logical(LogicalTypeFamily.NUMERIC)),
sequence(
logical(LogicalTypeFamily.NUMERIC),
logical(LogicalTypeFamily.INTEGER_NUMERIC, false))))
logical(LogicalTypeFamily.INTEGER_NUMERIC))))
.outputTypeStrategy(SpecificTypeStrategies.TO_TIMESTAMP_LTZ)
.runtimeClass(
"org.apache.flink.table.runtime.functions.scalar.ToTimestampLtzFunction")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import static org.apache.flink.table.api.DataTypes.TIMESTAMP_LTZ;
import static org.apache.flink.table.api.Expressions.$;
import static org.apache.flink.table.api.Expressions.call;
import static org.apache.flink.table.api.Expressions.lit;
import static org.apache.flink.table.api.Expressions.temporalOverlaps;
import static org.apache.flink.table.api.Expressions.toTimestampLtz;
import static org.apache.flink.table.planner.expressions.ExpressionBuilder.literal;
Expand Down Expand Up @@ -821,16 +822,10 @@ private Stream<TestSetSpec> toTimestampLtzTestCases() {
100,
1234,
-100,
null,
DecimalDataUtils.castFrom(-Double.MAX_VALUE, 38, 18),
100.01)
.andDataTypes(
DOUBLE(),
BIGINT(),
BIGINT(),
BIGINT(),
DataTypes.DECIMAL(38, 18),
FLOAT())
DOUBLE(), BIGINT(), BIGINT(), DataTypes.DECIMAL(38, 18), FLOAT())
.testResult(
toTimestampLtz($("f0")),
"TO_TIMESTAMP_LTZ(f0)",
Expand All @@ -853,18 +848,13 @@ private Stream<TestSetSpec> toTimestampLtzTestCases() {
.toInstant(),
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz($("f3"), literal(3)),
"TO_TIMESTAMP_LTZ(f3, 3)",
null,
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz($("f4"), literal(0)),
toTimestampLtz($("f3"), literal(0)),
"TO_TIMESTAMP_LTZ(-" + Double.MAX_VALUE + ", 0)",
null,
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz($("f5"), literal(3)),
"TO_TIMESTAMP_LTZ(f5, 3)",
toTimestampLtz($("f4"), literal(3)),
"TO_TIMESTAMP_LTZ(f4, 3)",
LocalDateTime.of(1970, 1, 1, 0, 0, 0, 100000000)
.atZone(ZoneOffset.UTC)
.toInstant(),
Expand Down Expand Up @@ -970,6 +960,51 @@ private Stream<TestSetSpec> toTimestampLtzTestCases() {
literal("UTC")),
"TO_TIMESTAMP_LTZ('un-parsable timestamp', 'yyyy-MM-dd HH:mm:ss', 'UTC')",
null,
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz(lit(123L), lit(null, DataTypes.INT())),
"TO_TIMESTAMP_LTZ(123, CAST(NULL AS INTEGER))",
null,
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz(lit(null, DataTypes.INT()), 3),
"TO_TIMESTAMP_LTZ(123, CAST(NULL AS INTEGER))",
null,
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz(null),
"TO_TIMESTAMP_LTZ(NULL)",
null,
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz(null, "yyyy-MM-dd HH:mm:ss.SSS"),
"TO_TIMESTAMP_LTZ(NULL, 'yyyy-MM-dd HH:mm:ss.SSS')",
null,
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz("1970-01-01 00:00:00.12345", null),
"TO_TIMESTAMP_LTZ('1970-01-01 00:00:00.12345', NULL)",
null,
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz(null, "dd/MM/yyyy HH:mm:ss", "America/Los_Angeles"),
"TO_TIMESTAMP_LTZ(NULL, 'dd/MM/yyyy HH:mm:ss', 'America/Los_Angeles')",
null,
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz("2023-01-01 00:00:00", null, "America/Los_Angeles"),
"TO_TIMESTAMP_LTZ('2023-01-01 00:00:00', NULL, 'America/Los_Angeles')",
null,
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz("2023-01-01 00:00:00", "dd/MM/yyyy HH:mm:ss", null),
"TO_TIMESTAMP_LTZ('2023-01-01 00:00:00', 'dd/MM/yyyy HH:mm:ss', NULL)",
null,
TIMESTAMP_LTZ(3).nullable())
.testResult(
toTimestampLtz(null),
"TO_TIMESTAMP_LTZ(NULL)",
null,
TIMESTAMP_LTZ(3).nullable()));
}
}

0 comments on commit 945487a

Please sign in to comment.