v.21.3New Feature
Add file engine settings: engine_file_empty_if_not_exists and engine_file_truncate_on_insert
Add file engine settings:engine_file_empty_if_not_existsandengine_file_truncate_on_insert. #20620 (M0r64n).
Why it matters
These settings improve control over the behavior of the File engine when the specified file does not exist and when data is inserted.engine_file_empty_if_not_exists allows returning an empty result instead of an error if the file is missing, while engine_file_truncate_on_insert enables truncating the file before inserting new data, facilitating better file management and more predictable data handling.How to use it
To use these features, set the table engine settings when creating or altering a File engine table. For example:CREATE TABLE table_name (...) ENGINE = File(format, 'path/to/file') SETTINGS engine_file_empty_if_not_exists = 1, engine_file_truncate_on_insert = 1;Setting
engine_file_empty_if_not_exists to 1 makes reads return empty results if the file doesn't exist. Setting engine_file_truncate_on_insert to 1 truncates the file on each insert instead of appending.