Repository navigation
Replies: 1 comment
|
thanks @jiangxt2 . This feature is reasonable, please go ahead! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'd like to discuss optional schema merging across files when querying Parquet or ORC directly through Doris file TVFs.
Use case and scope
The use case is ad hoc SQL over an evolving file directory, without first creating a table or registering a table schema. Newer files may contain a business field absent from historical files. Users may want the query to expose that field and fill missing values with NULL.
This proposal applies only to direct file TVFs, with an initial scope limited to supported scalar fields at the top level. It does not change the existing schema-management behavior of Doris tables or catalog tables. The TVF's query schema would be resolved before execution and remain fixed for that query.
I contributed Ray Data's opt-in full schema inference for Parquet and ORC, both merged. I also developed the independent open-source ray-doris connector, which enables Ray Data to read Doris data directly.
In a supporting Ray DataSourceV2 build,
merge_schema=Trueinspects all eligible files; the default uses bounded sampling. Doris file TVFs use the first file's schema by default. More precisely, the 4.1.5 selection path picks the first non-directory, non-zero-byte entry in its file list. That does not guarantee selection by filename, creation time, or upload order.Direct-query observations
I tested these objects in S3-compatible storage, separately for Parquet and ORC:
id BIGINT, event STRINGid=1, event='click'id BIGINT, event STRING, campaign STRINGid=2, event='purchase', campaign='winter'For each format, I created two prefixes containing byte-identical copies:
old_first/used000-oldand001-new, whilenew_first/exchanged the names to001-oldand000-new, with the appropriate format suffix. These are test labels, not ordering guarantees. The field sets and rows below come from eachSELECT *statement's own returned column metadata and rows.DESC FUNCTIONwas a separate diagnostic statement; it does not pin the selected file for a laterSELECT.With an S3 resource configured for connection settings:
The other cases substitute
new_first/or the ORC path and format.ORDER BYsorts result rows only.merge_schema=Trueid, event, campaignold_first/id, eventnew_first/id, event, campaignFor both formats, each
SELECT *returned two rows. In these runs, a separateSELECTofcampaignfailed with an unknown-column error forold_first/. TheSELECT *results fornew_first/returned NULL in the older row andwinterin the newer row. No CTAS or persistent target table was involved in these observations.These results follow the documented default. I tested with Doris 4.1.5 FE/BE images. The Ray comparison used a development build containing the merged inference changes and PyArrow 23.0.1. The retained reproduction material includes fixture hashes, image digests, SQL, inferred schemas and raw outputs.
Proposed behavior
merge_schema, initially for Parquet/ORC S3/HDFS file queries.This adds metadata I/O during analysis, even for queries that later read few rows. Concurrency, timeout and cancellation details can be settled during design. A retained file list does not provide an atomic snapshot of an S3/HDFS directory or prevent objects from changing during execution.
Related work
The Lance multi-dataset TVF discussion in #66492 considered schema union. The subsequent review narrowed the first stage to identical schemas, as reflected in #69276. This is related design context, rather than a Parquet/ORC cross-file schema-merge implementation.
CTAS can propagate the inferred field set into its target table; that is supplementary downstream context, not the motivation for this direct-query proposal.
Questions
All reactions