Skip to content

[Feature](File) Support FILE type - #4380

Open
linrrzqqq wants to merge 5 commits into
apache:masterfrom
linrrzqqq:file-type-docs
Open

linrrzqqq wants to merge 5 commits into
apache:masterfrom
linrrzqqq:file-type-docs

Conversation

@linrrzqqq

Copy link
Copy Markdown
Contributor

Versions

  • dev
  • 4.x (Since 4.2.0)
  • 3.x
  • 2.1 or older (not covered by version/language sync gate)

Languages

  • Chinese
  • English

Docs Checklist

  • Checked by AI
  • Test Cases Built
  • Updated required version and language counterparts, or explained why not
  • If only one language changed, confirmed whether source/translation counterparts need sync

- FILE is available in query expressions. FILE columns cannot be declared in internal tables or external catalogs, including FILE nested in containers.
- Whole FILE values and containers containing FILE cannot be used for comparison, sorting, hashing, grouping, DISTINCT, or MAP keys. Extract an ordinary scalar field for these operations.
- FILE supports explicit conversion to and from STRUCT, JSON, and VARIANT. There is no implicit conversion between FILE and these types; use CAST. See [FILE Type Conversion](../conversion/file-conversion.md).
- FILE arguments, return values, and aggregate intermediate types are unsupported in UDFs, including nested FILE.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FILE 是不是也不支持存储

Use an explicit CAST to construct FILE from a six-field STRUCT, JSON, or VARIANT value. Fields whose values are NULL must still be included. This conversion does not access remote storage.

```sql
SELECT CAST(NAMED_STRUCT(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们要支持cast 这个方式吗?还是说我们支持一些函数,比如底下这个to_file 这样的额就行了?


### Construct from metadata

Use an explicit CAST to construct FILE from a six-field STRUCT, JSON, or VARIANT value. Fields whose values are NULL must still be included. This conversion does not access remote storage.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们cast from json 不是很稳
如果要支持cast,我们就支持cast from struct ,其他的感觉不要支持了

Use an explicit CAST to construct FILE from a six-field STRUCT, JSON, or VARIANT value. Fields whose values are NULL must still be included. This conversion does not access remote storage.

```sql
SELECT CAST(NAMED_STRUCT(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们还需要提供一个函数,通过一个json 转FILE


## Element Access

Read a field with `ELEMENT_AT(f, 'field_name')` or the equivalent bracket syntax `f['field_name']`. The field name must be a non-NULL constant string and is case-insensitive. Unknown field names, dynamic selectors, and numeric indexes produce errors. Accessing a NULL FILE or a NULL field returns NULL.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我有一个问题啊,FILE 里面不同的属性类型可能不一样,你现在都用element at,咋区分的?

```sql
SELECT *
FROM LIST_FILE(
"resource" = "file_test_s3_resource",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个怎么控制是否读取binary 呢

Non-recursive: list files in the current directory only.

```sql
SELECT *

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to list_files

SELECT *
FROM LIST_FILE(
"resource" = "file_test_s3_resource",
"uri" = "s3://linrrzqqq/doris-file-type-test/",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果有一个额目录,我们是把目录显示成0,还是直接忽略了?

JSON 对象须恰好包含 uri、offset、size、content_type、checksum、inline 六个小写 key。offset 和 size 接受 BIGINT 范围的 JSON 整数或 null;inline 接受标准、带 padding 的 Base64 字符串或 null,空字符串表示空字节序列。

```sql
SELECT CAST(JSON_PARSE(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的cast 容易翻车,比如这个json 假如不符合要求,我们是报错,还是返回null,就会有那种严格模式的引入。
struct 是确定的。所以我建议不要写这个cast from json or variant了

+------------------------------------------------------------------------------------------------------------------+
```

### TO JSON

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些to json 之类的也不支持了

Restore JSON conversion pages to their pre-FILE contents and document FILE
casts through STRUCT. Describe TO_JSON(FILE), including all six fields,
Base64 inline data, and NULL handling, with executable examples.

Synchronize current and 4.x documentation in English and Chinese.

Validation: compile all 16 changed MDX pages; check internal links and locale
mirrors; execute three documentation SQL examples against Doris.
Describe path, size and nullable FILE results, default recursive listing,
and immediate directories with zero size and NULL FILE values. Synchronize
current and 4.x documentation in English and Chinese, including FILE and
TO_FILE references.

Validation: 12 MDX pages, internal links and locale/version synchronization;
three SQL examples verified against real MinIO storage.
Document FL_GET_BINARY, FILE metadata access, and explicit STRUCT to FILE conversion, including nested values and NULL handling. Update the English and Chinese current and 4.x documentation and function navigation.

Validation: Compiled all eight translated pages as MDX, checked 15 relative links, and ran git diff --check.

This branch had an error being deployed

1 failed (outdated) deployment
Production — efd796ee Deployed Oct 23, 2026 by linrrzqqq via Build Check #8951
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants