slinkydeveloper commented on a change in pull request #17776:
URL: https://github.com/apache/flink/pull/17776#discussion_r751281953
##########
File path:
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/FileSystemITCaseBase.scala
##########
@@ -368,6 +372,63 @@ trait FileSystemITCaseBase {
)
}
+ @Test
+ def testReadAllMetadata(): Unit = {
+ if (!supportsReadingMetadata) {
+ return
+ }
+
+ tableEnv.executeSql(
+ s"""
+ |create table metadataTable (
+ | x string,
+ | filepath string metadata,
+ | filename string metadata,
+ | size bigint metadata,
+ | modification_time timestamp_ltz metadata
+ |) with (
+ | 'connector' = 'filesystem',
+ | 'path' = '$resultPath',
+ | ${formatProperties().mkString(",\n")}
+ |)
+ """.stripMargin
+ )
+
+ tableEnv.executeSql(
+ "insert into nonPartitionedTable (x) select x from originalT limit
1").await()
+
+ checkPredicate(
+ "select * from metadataTable",
+ row => {
+ assertEquals(5, row.getArity)
+
+ // Only one file, because we don't have partitions
+ val file = new File(URI.create(resultPath).getPath).listFiles()(0)
+
+ assertEquals(
+ file.getPath,
+ row.getFieldAs[String](1)
+ )
+ assertEquals(
+ Paths.get(file.toURI).getFileName.toString,
+ row.getFieldAs[String](2)
+ )
+ assertEquals(
+ file.length(),
+ row.getFieldAs[Long](3)
+ )
+ assertEquals(
+ // Note: It's TIMESTAMP_LTZ
+ Instant.ofEpochMilli(file.lastModified())
+ .atZone(DateTimeUtils.UTC_ZONE.toZoneId)
Review comment:
Because `file.lastModified()` millis is adjusted to the local time zone.
But the type here is TIMESTAMP_LTZ, which means that effectively when we write
the record, the timestamp needs to be adjusted to UTC. That's why all this time
weirdness (and that's the reason for below comment as well)
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]