wuchong commented on a change in pull request #15363:
URL: https://github.com/apache/flink/pull/15363#discussion_r602071178
##########
File path:
flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/LogicalTypeCastsTest.java
##########
@@ -155,7 +157,41 @@
new VarCharType(Integer.MAX_VALUE),
false,
false
- }
+ },
+ {
+ new RowType(
+ Arrays.asList(
+ new RowField("f1", new IntType()),
+ new RowField("f2", new IntType()))),
+ new VarCharType(Integer.MAX_VALUE),
+ false,
+ false
+ },
+ // test implicit cast between timestamp type and
timestamp_ltz type
+ {new TimestampType(9), new TimestampType(9), true, true},
+ {new LocalZonedTimestampType(9), new
LocalZonedTimestampType(9), true, true},
+ {new TimestampType(3), new LocalZonedTimestampType(3),
true, true},
+ {new LocalZonedTimestampType(3), new TimestampType(3),
true, true},
+ {new TimestampType(3), new LocalZonedTimestampType(6),
true, true},
+ {new LocalZonedTimestampType(3), new TimestampType(6),
true, true},
+ {new TimestampType(3), new LocalZonedTimestampType(6),
true, true},
Review comment:
duplicate.
##########
File path:
flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/LogicalTypeCastsTest.java
##########
@@ -155,7 +157,41 @@
new VarCharType(Integer.MAX_VALUE),
false,
false
- }
+ },
+ {
+ new RowType(
+ Arrays.asList(
+ new RowField("f1", new IntType()),
+ new RowField("f2", new IntType()))),
+ new VarCharType(Integer.MAX_VALUE),
+ false,
+ false
+ },
Review comment:
This is duplicated.
##########
File path:
flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/LogicalTypeCastsTest.java
##########
@@ -155,7 +157,41 @@
new VarCharType(Integer.MAX_VALUE),
false,
false
- }
+ },
+ {
+ new RowType(
+ Arrays.asList(
+ new RowField("f1", new IntType()),
+ new RowField("f2", new IntType()))),
+ new VarCharType(Integer.MAX_VALUE),
+ false,
+ false
+ },
+ // test implicit cast between timestamp type and
timestamp_ltz type
+ {new TimestampType(9), new TimestampType(9), true, true},
+ {new LocalZonedTimestampType(9), new
LocalZonedTimestampType(9), true, true},
+ {new TimestampType(3), new LocalZonedTimestampType(3),
true, true},
+ {new LocalZonedTimestampType(3), new TimestampType(3),
true, true},
+ {new TimestampType(3), new LocalZonedTimestampType(6),
true, true},
+ {new LocalZonedTimestampType(3), new TimestampType(6),
true, true},
+ {new TimestampType(3), new LocalZonedTimestampType(6),
true, true},
+ {new LocalZonedTimestampType(3), new TimestampType(6),
true, true},
Review comment:
duplicate.
##########
File path:
flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/LogicalTypeCastsTest.java
##########
@@ -155,7 +157,41 @@
new VarCharType(Integer.MAX_VALUE),
false,
false
- }
+ },
+ {
+ new RowType(
+ Arrays.asList(
+ new RowField("f1", new IntType()),
+ new RowField("f2", new IntType()))),
+ new VarCharType(Integer.MAX_VALUE),
+ false,
+ false
+ },
+ // test implicit cast between timestamp type and
timestamp_ltz type
+ {new TimestampType(9), new TimestampType(9), true, true},
+ {new LocalZonedTimestampType(9), new
LocalZonedTimestampType(9), true, true},
+ {new TimestampType(3), new LocalZonedTimestampType(3),
true, true},
+ {new LocalZonedTimestampType(3), new TimestampType(3),
true, true},
+ {new TimestampType(3), new LocalZonedTimestampType(6),
true, true},
+ {new LocalZonedTimestampType(3), new TimestampType(6),
true, true},
+ {new TimestampType(3), new LocalZonedTimestampType(6),
true, true},
+ {new LocalZonedTimestampType(3), new TimestampType(6),
true, true},
+ {new TimestampType(false, 3), new
LocalZonedTimestampType(6), true, true},
+ {new LocalZonedTimestampType(false, 3), new
TimestampType(6), true, true},
Review comment:
Add tests cast from higher precision to lower precision.
##########
File path:
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/runtime/batch/sql/CalcITCase.scala
##########
@@ -392,6 +392,34 @@ class CalcITCase extends BatchTestBase {
Timestamp.valueOf("2019-09-19 08:03:09").toInstant)))
}
+ @Test
+ def testTimeUDFParametersImplicitCast(): Unit = {
+ val data = Seq(row(
+ localDateTime("2019-09-19 08:03:09"),
+ Timestamp.valueOf("2019-09-19 08:03:09"),
+ Timestamp.valueOf("2019-09-19 08:03:09").toInstant))
+ registerCollection("MyTable", data,
+ new RowTypeInfo(LOCAL_DATE_TIME, TIMESTAMP, INSTANT),
+ "a, b, c")
Review comment:
Would be better to use DDL to register tables which can explicitly
define sql types. We can also add different precision columns, e.g.
```scala
val ddl =
"""
|CREATE TABLE src (
| ntz TIMESTAMP(3),
| ltz0 TIMESTAMP_LTZ(0),
| ltz3 TIMESTAMP_LTZ(3),
| ltz6 TIMESTAMP_LTZ(6),
| ltz9 TIMESTAMP_LTZ(9),
| ltz_not_null TIMESTAMP_LTZ(3) NOT NULL
|) WITH (
| 'connector' = 'values',
| ...
|)
|""".stripMargin
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]