liuerbao created FLINK-38936:
--------------------------------
Summary: 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 Version: Flink 2.2.0.
Deployment: Standalone Cluster + local.
Reporter: liuerbao
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.
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)