slinkydeveloper commented on a change in pull request #17776:
URL: https://github.com/apache/flink/pull/17776#discussion_r752013297



##########
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:
       I must be honest, I don't know if there's a difference here per 
filesystem. I'm pretty sure the local filesystem returns the time in the local 
time zone, because if you look how `FileStatus` is built, it invokes this 
method: 
https://docs.oracle.com/javase/8/docs/api/java/io/File.html#lastModified-- 




-- 
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]


Reply via email to