fileINPUTBUFFERPROCESSOROUTPUT
文件(File)
文件输入(Input)通过 DataFusion 读取 JSON / CSV / Parquet / Avro / Arrow 文件。它支持本地路径与云对象存储(S3、GCS、Azure、HTTP、HDFS),并可选地对文件数据执行 SQL,或与 Ballista 分布式引擎集成。
配置
| Field | Type | Required | Default | 描述 |
|---|---|---|---|---|
| type | string | yes | — | 常量值 "file"(输入类型) |
| input_type | object | yes | — | 格式与位置,见下文:type(json / csv / parquet / avro / arrow)、path(文件路径或对象存储 URL)、可选 store(对象存储配置,带标签的枚举) |
| query | object | no | — | 对文件数据执行的 SQL,见下表(input_type 的同级字段) |
| ballista | object | no | — | 分布式查询配置,见下表(input_type 的同级字段) |
注意:
type、path、store位于input_type内部;query与ballista是input_type的同级字段(文件输入的顶层字段)。代码中的字段名是store(而不是旧文档中的object_store)。
store
store 是一个带标签的枚举(tagged enum,通过 type 字段区分)。
S3
| Field | Type | Required | Default | 描述 |
|---|---|---|---|---|
| type | string | yes | — | "s3" |
| bucket_name | string | yes | — | S3 存储桶名称 |
| access_key_id | string | yes | — | AWS 访问密钥 ID |
| secret_access_key | string | yes | — | AWS 秘密访问密钥 |
| endpoint | string | no | — | 自定义端点(MinIO 等) |
| region | string | no | — | AWS 区域 |
| allow_http | boolean | no | false | 是否允许 HTTP(非 TLS)连接 |
GCS (gs)
| Field | Type | Required | 描述 |
|---|---|---|---|
| type | string | yes | "gs" |
| bucket_name | string | yes | GCS 存储桶名称 |
| url | string | no | 自定义端点:gs://bucket(须与 bucket_name 同名)或指向模拟器的 http(s):// 端点(桶仍由 bucket_name 决定) |
| service_account_path | string | 见下注 | 服务账号 JSON 密钥文件的路径 |
| service_account_key | string | 见下注 | 服务账号 JSON 原始内容 |
service_account_path/service_account_key二者必须恰好提供一个:都不给会报 "GCS auth is missing",两个都给会报 "Specify either … not both"。
Azure (az)
| Field | Type | Required | 描述 |
|---|---|---|---|
| type | string | yes | "az" |
| account | string | yes | 存储账号名称 |
| container_name | string | yes | 容器名称 |
| endpoint | string | no | 端点 |
| url | string | no | Blob 端点 URL |
| access_key | string | no | 存储访问密钥 |
HTTP
| Field | Type | Required | 描述 |
|---|---|---|---|
| type | string | yes | "http" |
| url | string | yes | 存储源点(scheme://host[:port]);路径前缀应写入数据 path(如 path: http://host/prefix/file.parquet) |
HDFS
| Field | Type | Required | 描述 |
|---|---|---|---|
| type | string | yes | "hdfs" |
| url | string | yes | HDFS namenode URL |
| ha_config | map<string, string> | no | 高可用配置 |
query
| Field | Type | Required | Default | 描述 |
|---|---|---|---|---|
| query | string | yes | — | SQL 查询语句 |
| table | string | no | "flow" | 文件数据注册所使用的表名 |
ballista
| Field | Type | Required | 描述 |
|---|---|---|---|
| remote_url | string | yes | Ballista 服务器 URL |
示例
input:
type: "file"
input_type:
type: "json"
path: "/data/sensor_data.json"
input:
type: "file"
input_type:
type: "parquet"
path: "s3://my-bucket/data/sensor_readings.parquet"
store:
type: "s3"
region: "us-west-2"
bucket_name: "my-bucket"
access_key_id: "${AWS_ACCESS_KEY_ID}"
secret_access_key: "${AWS_SECRET_ACCESS_KEY}"
input:
type: "file"
input_type:
type: "csv"
path: "/data/sensors.csv"
query:
query: "SELECT sensor_id, AVG(temperature) as avg_temp FROM flow GROUP BY sensor_id"
table: "sensor_data"
input:
type: "file"
input_type:
type: "parquet"
path: "s3://analytics/data.parquet"
store:
type: "s3"
endpoint: "http://localhost:9000"
region: "us-east-1"
bucket_name: "analytics"
access_key_id: "minioadmin"
secret_access_key: "minioadmin"
allow_http: true
input:
type: "file"
input_type:
type: "csv"
path: "az://my-container/data/input.csv"
store:
type: "az"
account: "mystorageaccount"
container_name: "my-container"
access_key: "${AZURE_STORAGE_ACCESS_KEY}"
读取错误
已读出行之后的读取失败按原因分类:暂态检索失败(IO 错误、对象存储中断)返回 Disconnection,引擎重连并从头重读快照;确定性失败(文件损坏、schema 错误)以 Error::Process 终止运行,不会循环重连。读到数据末尾仍是干净的 EOF。