You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "LiJie20190102 (via GitHub)" <gi...@apache.org> on 2026/02/10 06:03:21 UTC

[PR] [Feature][Connector-V2][File-Source]Support metadata column for file source connector [seatunnel]

LiJie20190102 opened a new pull request, #10478:
URL: https://github.com/apache/seatunnel/pull/10478

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   -->
   
   ### Purpose of this pull request
   
   Implement feature #9737 
   
   
   ### Does this PR introduce _any_ user-facing change?
   no
   
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released SeaTunnel versions or within the unreleased branches such as dev.
   If no, write 'No'.
   If you are adding/modifying connector documents, please follow our new specifications: https://github.com/apache/seatunnel/issues/4544.
   -->
   
   
   ### How was this patch tested?
   
   Added unit tests and e2e tests. You can refer to the file configuration for guidance:
   
   ```
   env {
     parallelism = 1
     job.mode = "BATCH"
   
   }
   
   source {
     LocalFile {
       path = "/opt/soft/seatunnel/0209/seatunnel-2.3.13/tmp"
       file_format_type = "text"
       schema = {
         fields {
           a1 = "string"
         }
       }
     }
   }
   
   transform {
     Metadata {
       metadata_fields {
         FilePath = file_path
         FileUpdateTime = file_update_time
         FileSize = file_size
         FileType = file_type
       }
     }
   }
   
   
   sink {
     Assert {
       rules {
         row_rules = [
           {
             rule_type = MAX_ROW
             rule_value = 5
           }
         ],
         field_rules = [
           {
             field_name = file_path
             field_type = string
             field_value = [
               {
                 rule_type = NOT_NULL
               }
             ]
           },
           {
             field_name = file_update_time
             field_type = long
             field_value = [
               {
                 rule_type = NOT_NULL
               }
             ]
           },
           {
             field_name = file_size
             field_type = long
             field_value = [
               {
                 rule_type = NOT_NULL
               }
             ]
           },
           {
             field_name = file_type
             field_type = string
             field_value = [
               {
                 rule_type = NOT_NULL
               }
             ]
           }
         ]
       }
     }
   }
   ```
   
   
   
   
   
   ### Check list
   
   * [√ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [√ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [√ ] If necessary, please update `incompatible-changes.md` to describe the incompatibility caused by this PR.
   * [√ ] If you are contributing the connector code, please check that the following files are updated:
     1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2][File-Source]Support metadata column for file source connector [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10478:
URL: https://github.com/apache/seatunnel/pull/10478#issuecomment-5129173188

   Thanks for the update. I rechecked the current head `b9b4b3ce41cd` against the latest `dev`. This branch is currently `diverged` (`ahead_by=4`, `behind_by=53`), and the current `Build` check is `FAILURE`: https://github.com/apache/seatunnel/runs/88977648831
   
   The latest `dev` branch has a newer green `On pull request update` run (https://github.com/apache/seatunnel/actions/runs/30529407120, head `40700ad6241a`), so this CI signal is not very actionable on the stale PR head yet. The lowest-cost next step is to sync with the latest `dev` and rerun the failing check first. If it still fails after the sync, please share the new failing check link and I can help narrow it down against the updated head.
   
   This is in addition to the earlier source-level review items; those code-side blockers still need to be fixed 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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2][File-Source]Support metadata column for file source connector [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10478:
URL: https://github.com/apache/seatunnel/pull/10478#issuecomment-5167163027

   Rechecked the latest head on August 3, 2026: the earlier failing CI signal I referenced is no longer the current fact. The latest head is now pending in CI again, and GitHub is also reporting merge conflicts against `dev`.
   
   From Daniel's side I do not see a new source-level blocker on this head; the remaining gates at this point are the merge conflicts plus the current pending checks. Could you please sync with the latest `dev` and resolve the conflicts first? Once that is done and the checks are rerun, I'm happy to take another look.
   
   I only have read-only review controls in this repository, so a maintainer with write access may still need to handle the final approval or dismissal step after the branch is mergeable again.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2][File-Source]Support metadata column for file source connector [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10478:
URL: https://github.com/apache/seatunnel/pull/10478#issuecomment-4278477569

   Thanks for working on this, @LiJie20190102. The feature is genuinely useful: exposing `FilePath`, file time, size, and type through the existing Metadata transform would make file lineage and troubleshooting much easier for users.
   
   I reviewed the PR from a local branch (`seatunnel-review-10478`, head `fa4afaceba0bccd8613f0b3b38a9306bf10dd73c`, merge-base `17448dd989079ef3cded93ac3ebe67df90dcb2bb`) and followed the actual File Source -> Metadata transform -> engine transport paths. I also checked the current CI logs. My conclusion is:
   
   ### Conclusion: can merge after fixes
   
   #### Blocking items
   
   **Issue 1: the metadata is written to `SeaTunnelRow.options`, but Spark and Zeta transport boundaries do not preserve `options`.**
   
   Locations:
   - `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java:633`
   - `seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/serialization/InternalRowConverter.java:167`
   - `seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/serializable/RecordSerializer.java:50`
   
   The File readers now call `buildFileMetadata()` and then put the values into `SeaTunnelRow.options`. The Metadata transform later reads values with `inputRow.getOptions().get(metadataFieldName)`.
   
   That works only while the same `SeaTunnelRow` object is preserved. In the real Spark path, `InternalRowConverter.parcel()` writes row kind, table id, and physical fields into Spark `InternalRow`, but it does not write `options`; `unpack()` then rebuilds a new `SeaTunnelRow` without options. Zeta has the same boundary risk: `RecordSerializer` writes table id, row kind, arity, and fields only.
   
   The current CI already proves this is not theoretical. The new local file metadata E2E fails because `file_path` is `null`:
   
   ```text
   AssertConnectorException ... fail rule: AssertFieldRule(fieldName=file_path, fieldType=STRING, ruleType=NOT_NULL)
   ```
   
   The full runtime path is:
   
   ```text
   File Source initialization
     -> BaseFileSourceConfig.parseCatalogTable()
         -> newCatalogTable()
             -> buildMetadataSchema()
                 -> registers FilePath/FileCreateTime/FileUpdateTime/FileSize/FileType
   
   Read phase
     -> FileSourceReader
         -> ReadStrategy.read()
             -> readProcess(split, output, inputStream, partitionsMap, currentFileName)
                 -> buildFileMetadata(split, currentFileName)
                     -> hadoopFileSystemProxy.getFileStatus(split.getFilePath())
                     -> metadata.put(FilePath, currentFileName)
                     -> metadata.put(FileSize, fileStatus.getLen())
                 -> applyRowMetadata(row, tableId, metadata)
                     -> row.getOptions().putAll(metadata)
   
   Metadata transform expected path
     -> MetadataTransform.getOutputColumns()
         -> verifies the metadata field exists in CatalogTable.metadataSchema
     -> MetadataTransform.getOutputFieldValues()
         -> inputRow.getOptions().get("FilePath")
   
   Spark actual path
     -> InternalRowCollector.collect()
         -> InternalRowConverter.convert(row)
             -> parcel(row)
                 -> writes rowKind/tableId/fields only, not options
     -> MultiTableManager.reconvert()
         -> InternalRowConverter.unpack()
             -> creates a new SeaTunnelRow with empty options
     -> MetadataTransform reads FilePath
         -> inputRow.getOptions().get("FilePath") == null
     -> Assert E2E fails
   
   Zeta cross-task / queue path
     -> RecordSerializer.write()
         -> writes tableId/rowKind/fields only
     -> RecordSerializer.read()
         -> creates a new SeaTunnelRow with empty options
     -> MetadataTransform after that boundary cannot see FilePath either
   ```
   
   Suggested fix: either make metadata a first-class value that is carried across engine/translation boundaries, or extend Spark `InternalRowConverter` and Zeta `RecordSerializer` to serialize and restore options with backward-compatible format handling. Please add regression coverage for Spark and Zeta/File Source + Metadata transform, checking real values such as `FilePath` and `FileType`, not only non-null fields.
   
   **Issue 2: when no files are discovered, file metadata fields are not registered in the source metadata schema.**
   
   Locations:
   - `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/config/BaseFileSourceConfig.java:90`
   - `seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/metadata/MetadataTransform.java:128`
   
   When `filePaths` is empty, `parseCatalogTable()` returns the original `catalogTable` for non-binary formats. That bypasses `newCatalogTable()` and `buildMetadataSchema()`, so `FilePath`, `FileSize`, and the other file metadata fields are not available to the Metadata transform. Empty directories and `sync_mode=update` runs with no new files are normal user paths, so a valid config should not initialize differently only because there are currently no files.
   
   Please keep the physical schema fallback behavior, but still attach the file metadata schema when the user config can legitimately expose those fields.
   
   **Issue 3: the current Build is red, and the failures come from this PR's metadata changes.**
   
   Locations:
   - `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java:590`
   - `seatunnel-connectors-v2/connector-file/connector-file-base/src/test/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/ReadStrategySplitFallbackTest.java:86`
   - `seatunnel-e2e/seatunnel-connector-v2-e2e/connector-file-sftp-e2e/src/test/java/org/apache/seatunnel/e2e/connector/file/fstp/SftpFileIT.java:182`
   
   CI evidence:
   - `Build` is failing.
   - `ReadStrategySplitFallbackTest` has two NPEs at lines 86 and 120. The direct `readProcess()` tests do not initialize `hadoopFileSystemProxy`, while the new `buildFileMetadata()` now calls `hadoopFileSystemProxy.getFileStatus(...)` before reading.
   - `connector-file-local-e2e` fails because `file_path` is null in the metadata assertion.
   - `connector-file-sftp-e2e` fails because `testReadTextMetadata()` copies data to `/read/metadata` but executes `/json/sftp_to_access_for_json_path_filter.conf`, which reads `/read/filter`; the log reports `/tmp/seatunnel/read/filter` does not exist.
   
   Please make the lifecycle expectations explicit in the tests and fix the SFTP metadata E2E to execute the intended metadata config.
   
   **Issue 4: the PR currently conflicts with latest `dev`.**
   
   Locations:
   - `docs/en/transforms/metadata.md`
   - `docs/zh/transforms/metadata.md`
   
   A temporary merge with current `upstream/dev` conflicts in both metadata docs. Please rebase and merge the new file metadata rows with the already existing CDC/Kafka metadata documentation.
   
   #### Recommended follow-ups
   
   **Issue 5: archive metadata mixes inner entry identity with outer archive file status.**
   
   Locations:
   - `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java:372`
   - `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java:592`
   
   For ZIP/TAR/TAR_GZ, `currentFileName` is the inner entry name, so `FilePath` and `FileType` describe the entry. But `buildFileMetadata()` still calls `getFileStatus(split.getFilePath())`, so `FileSize`, `FileUpdateTime`, and `FileCreateTime` describe the outer archive. Users will see mixed metadata for one row.
   
   Please either make all fields describe the inner entry, or make all fields describe the outer archive and document that explicitly. I think the first option is more intuitive for users.
   
   **Issue 6: formatting check reports a trailing blank line.**
   
   Location:
   - `seatunnel-e2e/seatunnel-connector-v2-e2e/connector-file-hadoop-e2e/src/test/resources/fake_to_hdfs_text_normal.conf:56`
   
   `git diff --check upstream/dev...HEAD` reports `new blank line at EOF`.
   
   Overall, the feature direction is good and the PR already includes a lot of reader and E2E work. The important missing piece is the engine/translation contract: once file metadata can survive the real Spark/Zeta boundaries and the CI is green, this will be much closer to merge-ready.
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2][File-Source]Support metadata column for file source connector [seatunnel]

Posted by "DanielCarter-stack (via GitHub)" <gi...@apache.org>.
DanielCarter-stack commented on PR #10478:
URL: https://github.com/apache/seatunnel/pull/10478#issuecomment-3878744705

   <!-- code-pr-reviewer -->
   <!-- cpr:pr_reply_v2_parts {"group": "apache/seatunnel#10478", "part": 1, "total": 1} -->
   ### Issue 1: Inconsistent metadata setting in ExcelReaderListener
   
   **Location**: `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/excel/ExcelReaderListener.java:101`
   
   ```java
   // Current code
   seaTunnelRow.setTableId(tableId);
   seaTunnelRow.setOptions(metadata);  // Direct setting
   
   // All other places are
   applyRowMetadata(seaTunnelRow, tableId, metadata);  // Through method
   ```
   
   **Issue Description**:
   ExcelReaderListener directly calls `setOptions(metadata)`, while all other places use the `applyRowMetadata()` method. Although the effect is the same, it breaks code consistency.
   
   **Potential Risks**:
   - If `applyRowMetadata()` requires additional logic in the future (such as logging, validation), ExcelReaderListener will miss it
   - Easily overlooked during maintenance
   
   **Impact Scope**:
   - Direct impact: ExcelReadStrategy
   - Indirect impact: None
   - Affected area: Single Connector
   
   **Severity**: MINOR
   
   **Improvement Suggestion**:
   ```java
   // ExcelReaderListener.java:98-101
   - seaTunnelRow.setTableId(tableId);
   - seaTunnelRow.setOptions(metadata);
   + applyRowMetadata(seaTunnelRow, tableId, metadata);
   output.collect(seaTunnelRow);
   
   // Need to change applyRowMetadata method to public or protected, or add this method in ExcelReaderListener
   ```
   
   ---
   
   ### Issue 2: Extra getFileStatus() call added on every file read (Performance Issue)
   
   **Location**: `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java:590-604`
   
   ```java
   protected Map<String, Object> buildFileMetadata(FileSourceSplit split, String currentFileName)
           throws IOException {
       FileStatus fileStatus = hadoopFileSystemProxy.getFileStatus(split.getFilePath());  // Additional RPC call
       ...
   }
   ```
   
   **Issue Description**:
   For distributed file systems such as HDFS and S3, `getFileStatus()` is an RPC call that adds latency. For large file reads, this overhead may not be obvious, but for scenarios with many small files, the performance impact is significant.
   
   **Potential Risks**:
   - Significant performance degradation in scenarios with many small files
   - May become a performance bottleneck
   
   **Impact Scope**:
   - Direct impact: All scenarios using file source
   - Indirect impact: Entire pipeline throughput
   - Affected area: All file connectors
   
   **Severity**: CRITICAL
   
   **Improvement Suggestion**:
   ```java
   // Solution 1: Pre-fetch FileStatus when creating FileSourceSplit to avoid duplicate calls
   // Need to modify FileSourceSplit and FileSourceEnumerator
   public class FileSourceSplit implements SourceSplit {
       private final String tableId;
       private final String filePath;
       private final FileStatus fileStatus;  // Add
       ...
   }
   
   // Solution 2: Provide a switch for users to choose whether metadata is needed
   if (isMetadataEnabled()) {
       Map<String, Object> metadata = buildFileMetadata(split, currentFileName);
       applyRowMetadata(seaTunnelRow, tableId, metadata);
   } else {
       seaTunnelRow.setTableId(tableId);
   }
   
   // Solution 3: Cache FileStatus
   protected Map<String, Object> buildFileMetadata(FileSourceSplit split, String currentFileName, FileStatus cachedStatus) {
       FileStatus fileStatus = cachedStatus != null ? cachedStatus : hadoopFileSystemProxy.getFileStatus(split.getFilePath());
       ...
   }
   ```
   
   ---
   
   ### Issue 3: Extra system call added for local file system
   
   **Location**: `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java:606-631`
   
   ```java
   private Long resolveFileCreateTime(FileStatus fileStatus, String filePath) {
       ...
       if ("file".equalsIgnoreCase(scheme)) {
           try {
               URI uri = new Path(filePath).toUri();
               BasicFileAttributes attributes =
                       Files.readAttributes(Paths.get(uri), BasicFileAttributes.class);  // Additional system call
               ...
           } catch (Exception ignored) {
           }
       }
       ...
   }
   ```
   
   **Issue Description**:
   For local file system, `getFileStatus()` is already called (underlying is stat system call), then `Files.readAttributes()` is called again (stat again), causing duplicate system calls.
   
   **Potential Risks**:
   - Local file system read performance degradation
   - More noticeable in scenarios with many small files
   
   **Impact Scope**:
   - Direct impact: LocalFile connector
   - Indirect impact: None
   - Affected area: Single Connector
   
   **Severity**: MAJOR
   
   **Improvement Suggestion**:
   ```java
   // Solution 1: Only call when user explicitly needs FileCreateTime
   private Long resolveFileCreateTime(FileStatus fileStatus, String filePath, boolean needCreateTime) {
       if (!needCreateTime) {
           return fileStatus.getModificationTime() > 0 ? fileStatus.getModificationTime() : null;
       }
       ...existing code...
   }
   
   // Solution 2: Use FileStatus API (if available)
   // Note: Hadoop FileStatus may not have creation time, need to check specific version
   ```
   
   ---
   
   ### Issue 4: resolveFileCreateTime() swallows all exceptions
   
   **Location**: `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java:606-631`
   
   ```java
   private Long resolveFileCreateTime(FileStatus fileStatus, String filePath) {
       String scheme = null;
       try {
           scheme = hadoopFileSystemProxy.getFileSystem().getScheme();
       } catch (Exception ignored) {  // Swallow exception
       }
       if (StringUtils.isBlank(scheme)) {
           scheme = new Path(filePath).toUri().getScheme();
       }
       if ("file".equalsIgnoreCase(scheme)) {
           try {
               ...
           } catch (Exception ignored) {  // Swallow exception
           }
       }
       ...
   }
   ```
   
   **Issue Description**:
   Both catch blocks catch all exceptions but do nothing, which hides potential serious problems (such as insufficient permissions, unavailable file system, etc.), making problems difficult to debug.
   
   **Potential Risks**:
   - Hides real errors, increasing debugging difficulty
   - May return incorrect metadata values
   
   **Impact Scope**:
   - Direct impact: Metadata accuracy
   - Indirect impact: Debugging and problem location
   - Affected area: All file connectors
   
   **Severity**: MAJOR
   
   **Improvement Suggestion**:
   ```java
   private Long resolveFileCreateTime(FileStatus fileStatus, String filePath) {
       String scheme = null;
       try {
           scheme = hadoopFileSystemProxy.getFileSystem().getScheme();
       } catch (Exception e) {
           // Use logger instead of ignoring
           if (log.isDebugEnabled()) {
               log.debug("Failed to get filesystem scheme, using path scheme instead", e);
           }
       }
       if (StringUtils.isBlank(scheme)) {
           scheme = new Path(filePath).toUri().getScheme();
       }
       if ("file".equalsIgnoreCase(scheme)) {
           try {
               URI uri = new Path(filePath).toUri();
               BasicFileAttributes attributes =
                       Files.readAttributes(Paths.get(uri), BasicFileAttributes.class);
               long created = attributes.creationTime().toMillis();
               if (created > 0) {
                   return created;
               }
           } catch (Exception e) {
               // Use logger to record, but still fallback
               log.warn("Failed to get creation time for {}, fallback to modification time", filePath, e);
           }
       }
       ...
   }
   ```
   
   ---
   
   ### Issue 5: No logging when creation time falls back to modification time
   
   **Location**: `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java:628-630`
   
   ```java
   // Fallback to modification time for filesystems without creation time.
   long modificationTime = fileStatus.getModificationTime();
   return modificationTime > 0 ? modificationTime : null;
   ```
   
   **Issue Description**:
   When the file system does not support creation time, the code falls back to modification time, but there is no log record. Users may be confused why the value of `FileCreateTime` is the same as `FileUpdateTime`.
   
   **Potential Risks**:
   - User confusion
   - Difficult to troubleshoot problems
   
   **Impact Scope**:
   - Direct impact: User experience
   - Indirect impact: Support cost
   - Affected area: All file connectors
   
   **Severity**: MINOR
   
   **Improvement Suggestion**:
   ```java
   // Fallback to modification time for filesystems without creation time.
   long modificationTime = fileStatus.getModificationTime();
   if (log.isDebugEnabled() && modificationTime > 0) {
       log.debug("Filesystem does not support creation time, using modification time for {}", split.getFilePath());
   }
   return modificationTime > 0 ? modificationTime : null;
   ```
   
   ---
   
   ### Issue 6: addMetadataColumnIfAbsent() uses O(n²) algorithm
   
   **Location**: `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/config/BaseFileSourceConfig.java:201-207`
   
   ```java
   private void addMetadataColumnIfAbsent(List<Column> columns, MetadataColumn column) {
       for (Column existing : columns) {  // O(n) traversal
           if (existing.getName().equals(column.getName())) {
               return;
           }
       }
       columns.add(column);  // List.add() O(1) but may trigger expansion
   }
   ```
   
   **Issue Description**:
   Although there are only 5 fields and the impact is not significant, each call needs to traverse the entire list, which is not a best practice.
   
   **Potential Risks**:
   - Code quality
   - Maintainability
   
   **Impact Scope**:
   - Direct impact: Code quality
   - Indirect impact: None
   - Affected area: BaseFileSourceConfig
   
   **Severity**: MINOR
   
   **Improvement Suggestion**:
   ```java
   // Solution 1: Use Set for deduplication
   private Set<String> existingColumnNames = new HashSet<>();
   private void addMetadataColumnIfAbsent(List<Column> columns, MetadataColumn column) {
       if (existingColumnNames.add(column.getName())) {  // Set.add() returns false if already exists
           columns.add(column);
       }
   }
   
   // Solution 2: Use Stream
   private void addMetadataColumnIfAbsent(List<Column> columns, MetadataColumn column) {
       if (columns.stream().noneMatch(c -> c.getName().equals(column.getName()))) {
           columns.add(column);
       }
   }
   ```
   
   ---
   
   ### Issue 7: Lack of tests for different file systems
   
   **Location**: Test files
   
   **Issue Description**:
   Unit tests only cover the local file system (`TextReadStrategyTest` uses LocalConf), and there are no tests for HDFS, S3, SFTP, etc. Different file systems may have different support for `getScheme()`, `FileStatus`.
   
   **Potential Risks**:
   - Metadata for HDFS, S3 and other file systems may be incorrect
   - Problems are only discovered in E2E tests, increasing debugging costs
   
   **Impact Scope**:
   - Direct impact: Test coverage
   - Indirect impact: Code quality
   - Affected area: All non-local file systems
   
   **Severity**: MAJOR
   
   **Improvement Suggestion**:
   ```java
   // Add tests for different file systems
   @Test
   public void testHdfsFileMetadata() {
       // Use mock HDFS filesystem
       ...
   }
   
   @Test
   public void testS3FileMetadata() {
       // Use mock S3 filesystem
       ...
   }
   
   // At least test:
   // 1. Behavior when getScheme() returns different values
   // 2. Different values of FileStatus (e.g., modificationTime=0)
   // 3. Cases where creation time parsing succeeds and fails
   ```
   
   ---
   
   ### Issue 8: Lack of unit tests for resolveFileCreateTime()
   
   **Location**: Test files
   
   **Issue Description**:
   `resolveFileCreateTime()` is a complex private method involving multiple conditional branches and exception handling, but there are no dedicated unit tests.
   
   **Potential Risks**:
   - Logic errors are difficult to discover
   - Edge cases not covered
   
   **Impact Scope**:
   - Direct impact: Test coverage
   - Indirect impact: Code quality
   - Affected area: AbstractReadStrategy
   
   **Severity**: MAJOR
   
   **Improvement Suggestion**:
   ```java
   // Use reflection to test private methods, or change to package-private
   @Test
   public void testResolveFileCreateTimeWithLocalFile() throws Exception {
       ...
   }
   
   @Test
   public void testResolveFileCreateTimeWithHdfsFile() {
       ...
   }
   
   @Test
   public void testResolveFileCreateTimeWhenSchemeIsNull() {
       ...
   }
   
   @Test
   public void testResolveFileCreateTimeWhenModificationTimeIsZero() {
       ...
   }
   ```
   
   ---
   
   ### Issue 9: Lack of tests for exception scenarios
   
   **Location**: Test files
   
   **Issue Description**:
   Tests only verify normal cases, no testing for:
   - File does not exist
   - Insufficient permissions
   - FileStatus retrieval failure
   - Invalid file paths
   
   **Potential Risks**:
   - Improper exception handling leads to crashes
   - Poor user experience
   
   **Impact Scope**:
   - Direct impact: Test coverage
   - Indirect impact: Stability
   - Affected area: All ReadStrategy
   
   **Severity**: MINOR
   
   **Improvement Suggestion**:
   ```java
   @Test
   public void testBuildFileMetadataWhenFileNotExists() {
       ...
   }
   
   @Test
   public void testBuildFileMetadataWhenPermissionDenied() {
       ...
   }
   ```
   
   ---
   
   ### Issue 10: E2E tests only verify NOT_NULL
   
   **Location**: E2E test configuration file
   
   ```hocon
   field_value = [
     {
       rule_type = NOT_NULL
     }
   ]
   ```
   
   **Issue Description**:
   E2E tests only verify that fields are not null, and do not verify the correctness of values (such as whether file paths are correct, whether timestamps are reasonable).
   
   **Potential Risks**:
   - Value errors but tests pass
   - Problems are only discovered in production environment
   
   **Impact Scope**:
   - Direct impact: Test quality
   - Indirect impact: Product quality
   - Affected area: All E2E tests
   
   **Severity**: MINOR
   
   **Improvement Suggestion**:
   ```hocon
   // Besides NOT_NULL, should also verify:
   // 1. File path matches expectation
   // 2. File size is greater than 0
   // 3. Timestamp is reasonable (e.g., not negative, within reasonable range)
   // 4. File type is correct
   field_value = [
     {
       rule_type = NOT_NULL
     },
     {
       rule_type = "REGEX_MATCH"
       rule_value = ".*\\.txt"  // Verify file path
     }
   ]
   ```
   
   ---
   
   ### Issue 11: Documentation does not explicitly state which file systems support creation time
   
   **Location**: `docs/en/transforms/metadata.md:35`
   
   ```markdown
   4. **File metadata**: `FileCreateTime` can be null depending on filesystem or permissions; `FileType` is typically derived from the file extension.
   ```
   
   **Issue Description**:
   Documentation only says "can be null depending on filesystem", but does not explicitly state:
   - Which file systems support creation time (local with java.nio)
   - Which file systems do not support it (HDFS, S3, etc. will fall back to modification time)
   
   **Potential Risks**:
   - User confusion
   - Unreasonable expectations
   
   **Impact Scope**:
   - Direct impact: User experience
   - Indirect impact: Support cost
   - Affected area: Documentation
   
   **Severity**: MINOR
   
   **Improvement Suggestion**:
   ```markdown
   4. **File metadata**: 
      - `FileCreateTime`: Only supported on local filesystems (using `java.nio.file`). For other filesystems (HDFS, S3, SFTP, FTP, COS), it falls back to `FileUpdateTime`. Can be null if the underlying file metadata is unavailable.
      - `FileType`: Derived from the file extension (the part after the last dot). Empty string if no extension.
   ```
   
   ---
   
   ### Issue 12: Lack of performance metrics
   
   **Location**: All metadata-related code
   
   **Issue Description**:
   There is no monitoring of metadata construction performance (such as time consumed, frequency), making it impossible to evaluate performance impact in production environments.
   
   **Potential Risks**:
   - Performance problems are difficult to discover
   - Unable to optimize
   
   **Impact Scope**:
   - Direct impact: Observability
   - Indirect impact: Performance tuning
   - Affected area: All file connectors
   
   **Severity**: MINOR
   
   **Improvement Suggestion**:
   ```java
   protected Map<String, Object> buildFileMetadata(FileSourceSplit split, String currentFileName)
           throws IOException {
       long start = System.nanoTime();
       try {
           FileStatus fileStatus = hadoopFileSystemProxy.getFileStatus(split.getFilePath());
           ...
       } finally {
           long duration = System.nanoTime() - start;
           if (duration > 1_000_000) {  // Exceeds 1ms
               log.warn("Building file metadata took {} ms for {}", duration / 1_000_000, split.getFilePath());
           }
       }
   }
   ```
   
   ---
   
   ### Issue 13: Lack of debug logging
   
   **Location**: All metadata-related code
   
   **Issue Description**:
   There are no logs recording the metadata construction process, making it difficult to track problems during debugging.
   
   **Potential Risks**:
   - Problems are difficult to locate
   - Difficult to debug
   
   **Impact Scope**:
   - Direct impact: Observability
   - Indirect impact: Debugging efficiency
   - Affected area: All file connectors
   
   **Severity**: MINOR
   
   **Improvement Suggestion**:
   ```java
   protected Map<String, Object> buildFileMetadata(FileSourceSplit split, String currentFileName)
           throws IOException {
       if (log.isTraceEnabled()) {
           log.trace("Building metadata for file: {}", currentFileName);
       }
       FileStatus fileStatus = hadoopFileSystemProxy.getFileStatus(split.getFilePath());
       ...
       if (log.isDebugEnabled()) {
           log.debug("Built metadata for file: {}, size: {}, updateTime: {}", 
               currentFileName, fileStatus.getLen(), fileStatus.getModificationTime());
       }
       ...
   }
   ```
   
   ---
   
   ### Issue 14: SeaTunnelRow.options is transient and will not be serialized to checkpoint
   
   **Location**: `seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRow.java:37`
   
   ```java
   private Map<String, Object> options;  // Default is transient
   ```
   
   **Issue Description**:
   `SeaTunnelRow.options` field is transient (according to Java serialization rules, if not explicitly declared, but after reviewing the code, there is no transient modifier, needs confirmation). If indeed not serialized, metadata will be lost after checkpoint recovery.
   
   **Potential Risks**:
   - Metadata lost after checkpoint recovery
   - Downstream operators that depend on metadata may error
   
   **Impact Scope**:
   - Direct impact: Checkpoint recovery
   - Indirect impact: Data consistency
   - Affected area: All scenarios using metadata
   
   **Severity**: CRITICAL
   
   **Confidence**: Low (needs further confirmation)
   
   **Improvement Suggestion**:
   ```java
   // Need to confirm SeaTunnelRow serialization mechanism
   // If using custom serialization like Kryo, may not be affected
   // If using Java serialization, need to:
   private void writeObject(ObjectOutputStream out) throws IOException {
       out.defaultWriteObject();
       // Serialize options
   }
   
   private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
       in.defaultReadObject();
       // Deserialize options
   }
   ```
   
   ---
   
   ### Issue 15: Inconsistent naming of CommonOptions enum values
   
   **Location**: `seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/CommonOptions.java:69-74`
   
   ```java
   FILE_PATH("FilePath", true),
   FILE_CREATE_TIME("FileCreateTime", true),
   FILE_UPDATE_TIME("FileUpdateTime", true),
   FILE_SIZE("FileSize", true),
   FILE_TYPE("FileType", true);
   ```
   
   **Issue Description**:
   Enum names use uppercase underscore (`FILE_PATH`), but enum values use PascalCase (`FilePath`), which is inconsistent with the style of other enum constants (such as `IS_BINARY_FORMAT`). More importantly, metadata transform uses lowercase underscore (such as `file_path`), which may cause confusion.
   
   **Potential Risks**:
   - User confusion
   - Configuration errors
   
   **Impact Scope**:
   - Direct impact: User experience
   - Indirect impact: Configuration
   - Affected area: API
   
   **Severity**: MINOR
   
   **Improvement Suggestion**:
   ```java
   // Maintain consistency, use the same naming style everywhere
   // Documentation should clearly state:
   // - CommonOptions enum name: FILE_PATH (Java code)
   // - getName() return value: FilePath
   // - Metadata transform configuration: file_path (configuration file)
   ```
   
   ---


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2][File-Source]Support metadata column for file source connector [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #10478:
URL: https://github.com/apache/seatunnel/pull/10478#issuecomment-6394027418

   Updated the existing branch with commit `8461a8ef60bf465850288ed82297bfb32e8edda0`, merging current `dev` (`d676f91b3d6aaa2cca693816697a211e4d384805`) and preserving the newer Excel, Markdown, XML and Parquet behavior.
   
   The repair completes PDF file metadata, fixes extension detection under dotted parent directories, retains row options across the Spark conversion boundary, and fixes the S3 metadata test routing. Metadata assertions now require nonzero input and include all five fields: exact five rows for the controlled local/S3/FTP/SFTP fixtures, and 100 for the HDFS producer. COS retains its existing disabled external-fixture test with a 1–5 row bound; this is not claimed as runtime validation.
   
   Independent source review and formatting passed. Scoped Spotless succeeded for API, Spark common, file base/Hadoop and all six affected E2E modules. Local functional tests were not run under the project policy. The historical Build log is expired (HTTP 410); current-head GitHub CI is still required. The immediate readback confirms the new head and intended 44-file scope, with checks/mergeability not yet reported.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2][File-Source]Support metadata column for file source connector [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10478:
URL: https://github.com/apache/seatunnel/pull/10478#issuecomment-6473961732

   Thanks for the contribution. The CI fact cited in my previous conclusion has changed; this follow-up updates that gate on the unchanged reviewed head, without issuing another full source review.
   
   Gate snapshot (2026-10-28T16:00:43+00:00), head `8461a8ef60bf465850288ed82297bfb32e8edda0`: [Build](https://github.com/apache/seatunnel/runs/121485472726) is `ACTION_REQUIRED`.
   
   The exact blocking stage is **Build workflow-run detection**: the check says no fork Build was found for this SHA. This is not an executed test failure and does not by itself prove that fork Actions is disabled. Open the fork Actions tab, enable workflows if needed, then manually run the existing Build workflow for this PR branch. If a matching run already exists, link it for a maintainer to reconcile the aggregate. No empty commit or speculative dependency change is requested.
   
   Upstream check: current dev retains the fork-run adoption workflow and its scheduled/manual status-refresh path. A base sync alone cannot enable fork Actions or supply a missing exact-head workflow run, so I am not prescribing sync as the fix for this activation gate.
   
   My [previous source conclusion](https://github.com/apache/seatunnel/pull/10478#pullrequestreview-5642901144) remains unchanged, including its independent source/documentation requests. CI is not being passed by inference, and this follow-up is not an effective approval.
   
   Comparison recorded in this scan: base `dev`, `diverged`, ahead 5 / behind 48, no merge conflict. Branch drift is metadata here and is not an additional sync request.
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org