[ 
https://issues.apache.org/jira/browse/FLINK-38936?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18052556#comment-18052556
 ] 

liuerbao commented on FLINK-38936:
----------------------------------

Possible solutions:

Modify:

module: flink-connector-files,

package: package org.apache.flink.connector.file.table;

class: FileSystemTableSource,

at line 512 of the code:

Paths.get(split.path().getPath()).getFileName().toString(),

change it to split.path().getName().

 

> FileSystem SQL Connector,The connector metadata file.name, Caused by: 
> java.nio.file.InvalidPathException: Illegal char <:> at index 2
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-38936
>                 URL: https://issues.apache.org/jira/browse/FLINK-38936
>             Project: Flink
>          Issue Type: Bug
>          Components: Connectors / FileSystem
>    Affects Versions: 2.2.0
>         Environment: Windows:
> !image-2026-01-17-14-08-07-962.png|width=376,height=105!
> Flink:
> Flink 2.2.0.
> Deployment:   Standalone Cluster + local.
>  
> Java:
> Java 17.
>            Reporter: liuerbao
>            Priority: Minor
>         Attachments: image-2026-01-17-14-08-07-962.png, 
> image-2026-01-17-14-25-42-441.png
>
>
> In the Windows environment, when using the file.name metadata of the 
> FileSystem SQL Connector, the following error occurred: Caused by: 
> java.nio.file.InvalidPathException: Illegal char <:> at index.
> The reason is probably that the internal code interprets the path 
> "data\input" as the path 
> "file:/D:/AI-Book/FlinkApplication/data/input/user.csv" which contains the 
> drive letter "D:". Later, when parsing the file name from this path, it fails 
> to parse the colon in the drive letter.
> Possible solutions:
> Modify:
> module: flink-connector-files,
> package: package org.apache.flink.connector.file.table;
> class: FileSystemTableSource,
> at line 512 of the code:
> Paths.get(split.path().getPath()).getFileName().toString(),
> change it to split.path().getName().
>  
> FileSystem SQL Connector, The connector metadata file.name:
> !image-2026-01-17-14-25-42-441.png|width=312,height=164!
> code:
> import org.apache.flink.table.api.EnvironmentSettings;
> import org.apache.flink.table.api.TableEnvironment;
> public class CSVConnectorBug {
> public static void main(String[] args)
> { // Table Environment. EnvironmentSettings settings = EnvironmentSettings 
> .newInstance() .inStreamingMode() // 流模式. //.inBatchMode() // 批模式. .build(); 
> TableEnvironment tEnv = TableEnvironment.create(settings); String 
> createSourceTable = """ CREATE TABLE fs_source_table ( user_id STRING, name 
> STRING, age INT, file_name STRING NOT NULL METADATA FROM 'file.name' VIRTUAL 
> ) WITH ( 'connector'='filesystem', 'path'='data\\input' ,'format'='csv' ); 
> """; tEnv.executeSql(createSourceTable); System.out.println("源表创建成功!"); 
> String selectStat = """ SELECT user_id, name, age, file_name FROM 
> fs_source_table; """; tEnv.executeSql(selectStat).print(); }
> }



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to