Skip to main content
VeloDB Cloud 26.x is based on Apache Doris 4.x. See Version Mapping.

Handle Messy Data

Use strict mode and error thresholds to decide whether a load rejects invalid rows or fails its data-quality check. Source values can fail conversion to the target column type for several reasons:

  • Field type mismatch (for example, writing the string "abc" into a TinyInt column)
  • Field too long (for example, writing 11 ASCII characters into a CHAR(10) column)
  • Precision mismatch / numeric overflow (for example, writing 10 into a Decimal(1,0) column)

The controls differ by import method. The defaults below are the Core 26.1.3 implementation reference. Set them explicitly when a job requires a particular policy.

Import methodConversion or row-filtering controlFilter-ratio controlDefault values
Stream Load, Broker Load, MySQL Loadstrict_modemax_filter_ratiofalse, 0
Routine Loadstrict_modemax_filter_ratio, also subject to max_error_numberfalse, 1.0; error-count default 0
INSERT INTOenable_insert_strictinsert_max_filter_ratio when strict insert is disabledtrue, 1.0

Warning:

Non-strict loading can replace invalid values with NULL or truncate oversized strings. Increasing a filter threshold can discard rows. Neither setting validates business rules or guarantees complete source-data retention.

Before you start​

Create or select the target database, and use a warehouse SQL user with the required table and load permissions. Run the SQL examples in the stated database. Copy the Stream Load request URL from Connection Methods. Replace <endpoint> with its scheme, host, and port, and preserve HTTPS when it is required. Replace <username> with your warehouse SQL username. The curl commands prompt for your password.

For S3 or Kafka, replace the source paths, connection properties, and job names with values for your environment. Confirm network access and use the authentication method supported by your source and deployment. The S3 snippets illustrate access-key authentication. Each load method is an alternative: use a fresh example table and a unique load label or job name for each run. Query results illustrate the source examples and are not measurements from your warehouse.

Strict mode​

The main function of strict mode (strict_mode) is to filter out data rows whose column type conversion fails during the import process.

Conversion failure handling​

Depending on the strict mode setting, the system applies different processing strategies:

  • Strict mode disabled: Values that fail the supported column conversion can become NULL and load if the target column is nullable. Other parsing, schema, and execution errors can still reject rows or fail the load.
  • Strict mode enabled: The system filters out rows when a non-null direct source value becomes NULL after conversion to the target column type. A NULL produced by a derived expression is not itself a direct-conversion failure. Rows must still pass other parsing, schema, and execution checks.
  • NULL value handling: A source NULL is not a non-null-to-null conversion failure. A derived expression can also produce NULL. If the target column is defined as not allowing NULL values, data rows containing NULL values are filtered out.

The following three typical column type examples illustrate the behavioral differences when strict mode is enabled versus disabled.

Example 1: TINYINT conversion​

Compare valid, null, and invalid tiny integer inputs
Source data typeSource data exampleValue after conversion to TINYINTStrict modeResult
Null value\NNULLEnabled or disabledNULL
Non-null value"abc" or 2000NULLEnabledInvalid value (filtered)
Non-null value"abc" or 2000NULLDisabledNULL
Non-null value11Enabled or disabledImported correctly

Tip:

  1. The columns in the table allow null values to be imported.
  2. Converting abc or 2000 to TINYINT produces NULL because of invalid numeric syntax or overflow. Strict mode filters these rows. Non-strict mode imports NULL.

Example 2: DECIMAL(1,0) conversion​

Compare invalid decimal syntax and numeric overflow
Source data typeSource data exampleValue after conversion to DECIMAL(1,0)Strict modeResult
Null value\NNULLEnabled or disabledNULL
Non-null valueaaaNULLEnabledInvalid value (filtered)
Non-null valueaaaNULLDisabledNULL
Non-null value10NULL (overflow)EnabledFiltered
Non-null value10NULL (overflow)DisabledNULL

Tip:

  1. The columns in the table allow null values to be imported.
  2. Converting aaa to DECIMAL(1,0) produces NULL because it is not valid numeric input. Strict mode filters the row. Non-strict mode imports NULL.
  3. 10 exceeds the range of DECIMAL(1,0) and converts to NULL. Strict mode filters the row. Non-strict mode imports NULL.

Example 3: CHAR(10) length​

Compare strict rejection and non-strict ASCII truncation
Source data typeSource data exampleValue after conversion to CHAR(10)Strict modeResult
Null value\NNULLEnabled or disabledNULL
Non-null valuea1234567890a1234567890EnabledToo long, filtered
Non-null valuea1234567890a1234567890Disableda123456789 (truncated)

Tip:

The columns in the table allow null values. This example uses ASCII input. CHAR(10) limits the stored value to 10 bytes. Truncating multi-byte text does not guarantee that it fits the byte limit.

Enable strict mode​

strict_mode defaults to false for the file and stream load methods below. INSERT INTO uses the separate session variable enable_insert_strict, whose compiled default is true. SQL cast errors are also controlled by enable_strict_cast. Disabling strict insert does not suppress every cast or planning error.

Stream Load

curl --location-trusted -u "<username>" \
-H "strict_mode: true" \
-T data.txt \
"<endpoint>/api/example_db/test_table/_stream_load"

Broker Load

LOAD LABEL example_db.label_1
(
DATA INFILE("s3://bucket/data.txt")
INTO TABLE test_table
)
WITH S3
(
"s3.endpoint" = "https://<s3-endpoint>",
"s3.region" = "<region>",
"s3.access_key" = "<access-key>",
"s3.secret_key" = "<secret-key>"
)
PROPERTIES
(
"strict_mode" = "true"
);

Routine Load

CREATE ROUTINE LOAD example_db.job1 ON test_table
PROPERTIES
(
"strict_mode" = "true"
)
FROM KAFKA
(
"kafka_broker_list" = "<broker>:<port>",
"kafka_topic" = "<topic>",
"property.group.id" = "<consumer-group>"
);

MySQL Load

LOAD DATA LOCAL INFILE 'data.txt'
INTO TABLE test_table
PROPERTIES
(
"strict_mode" = "true"
);

INSERT INTO

SET enable_insert_strict = true;
INSERT INTO test_table SELECT * FROM source_table;

Maximum filter ratio​

The maximum filter ratio limits the proportion of rejected rows. Its value ranges from 0 to 1.

  • If the ratio is less than or equal to the threshold, the load passes this ratio check. Other errors can still fail it.
  • If the ratio exceeds the threshold, a batch load fails its quality check. Routine Load pauses when its accumulated ratio or error count exceeds the job threshold. Previously committed tasks are not rolled back.

How the filter ratio is calculated​

Load statistics distinguish the following categories:

CategoryDescription
Filtered RowsRows filtered out due to data quality issues. Data quality issues include type errors, precision errors, oversized string length, mismatched column counts in files, and other data format problems, as well as data rows filtered out because no corresponding partition exists.
Unselected RowsData rows filtered out by pre-filter or post-filter conditions.
Loaded RowsData rows that are imported correctly.

For batch loading with Stream Load, Broker Load, or MySQL Load, the filter ratio is:

#Filtered Rows / (#Filtered Rows + #Loaded Rows)

For Stream Load, Broker Load, and MySQL Load, Unselected Rows are excluded from this batch calculation. If no selected rows remain, there is no positive denominator to evaluate.

Routine Load uses a different accumulated calculation in the Core 26.1.3 implementation:

Filtered Rows / (Filtered Rows + Loaded Rows + Unselected Rows)

The job checks the accumulated ratio and max_error_number after task updates, and resets its sampling counters after they exceed max_batch_rows * 10 total rows. Either threshold can pause the job. With the default max_error_number=0, increasing max_filter_ratio alone does not allow error rows. Inspect ErrorLogUrls and the pause reason before correcting the source or thresholds and resuming the job. See Routine Load.

Set the maximum filter ratio​

max_filter_ratio defaults to 0 for Stream Load, Broker Load, and MySQL Load. Routine Load defaults to 1.0, with a separate max_error_number default of 0. The following file and stream load examples set a ratio of 0.1 (10%). The INSERT INTO example uses 0.5 to demonstrate the equality boundary. Choose an error-count allowance appropriate to your Routine Load job as well.

Stream Load

curl --location-trusted -u "<username>" \
-H "max_filter_ratio: 0.1" \
-T data.txt \
"<endpoint>/api/example_db/my_table/_stream_load"

Broker Load

LOAD LABEL example_db.label_1
(
DATA INFILE("s3://bucket/data.txt")
INTO TABLE test_table
)
WITH S3
(
"s3.endpoint" = "https://<s3-endpoint>",
"s3.region" = "<region>",
"s3.access_key" = "<access-key>",
"s3.secret_key" = "<secret-key>"
)
PROPERTIES
(
"max_filter_ratio" = "0.1"
);

Routine Load

CREATE ROUTINE LOAD example_db.job1 ON test_table
PROPERTIES
(
"max_filter_ratio" = "0.1"
)
FROM KAFKA
(
"kafka_broker_list" = "<broker>:<port>",
"kafka_topic" = "<topic>",
"property.group.id" = "<consumer-group>"
);

MySQL Load

LOAD DATA LOCAL INFILE 'data.txt'
INTO TABLE test_table
PROPERTIES
(
"max_filter_ratio" = "0.1"
);

INSERT INTO

The following example uses a threshold of 0.5 to demonstrate that equality passes the filter-ratio check.

CREATE TABLE insert_filter_ratio_example (id INT NOT NULL)
DUPLICATE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 1;

SET enable_insert_strict = false;
SET insert_max_filter_ratio = 0.5;
INSERT INTO insert_filter_ratio_example VALUES (1), (NULL);
SELECT * FROM insert_filter_ratio_example;
+------+
| id |
+------+
| 1 |
+------+

Because id does not allow NULL, the second row is filtered. The filter ratio is 1 / (1 + 1) = 0.5, which equals the threshold and passes the ratio check. The expected result contains only the accepted row.

Tip:

For INSERT INTO statements, insert_max_filter_ratio only takes effect when enable_insert_strict = false. Its compiled default is 1.0, which permits all rows eligible for filtering to be rejected. The control applies to both VALUES and SELECT, including reads from warehouse tables, external tables, and file table-valued functions. The statement fails the ratio check only when the actual ratio exceeds the threshold. Planning, cast, and other execution errors can still fail the statement.

FAQ​

Q1: How should strict_mode and max_filter_ratio be used together?

  • To reject direct conversion failures, set strict_mode=true. Set max_filter_ratio=0 if any rejected row must fail the batch quality check. Routine Load also checks max_error_number and pauses on a threshold violation.
  • To skip a limited proportion of rejected rows, keep strict_mode=true and choose the ratio deliberately, for example 0.1. For Routine Load, also set an appropriate error-count allowance.
  • Use strict_mode=false only when accepting conversion to NULL or truncation is intentional. Such accepted values are loaded rows and do not increase the filtered-row ratio.

Q2: Are NULL values produced by function computation filtered by strict mode?

No. Strict mode only targets direct conversion where the original value is not NULL but becomes NULL after column type conversion. A NULL produced by a derived expression is not itself a strict-mode conversion failure. However, a NOT NULL target column still rejects it.

Q3: Are data rows filtered by pre-filter or post-filter conditions counted toward max_filter_ratio?

For Stream Load, Broker Load, and MySQL Load, the denominator includes only Filtered Rows and Loaded Rows. The checked Core 26.1.3 Routine Load accumulator also includes Unselected Rows in its denominator. See How the filter ratio is calculated.

Q4: What is the relationship between enable_insert_strict and insert_max_filter_ratio in INSERT INTO?

insert_max_filter_ratio only takes effect when enable_insert_strict = false. Its compiled default is 1.0, which permits all rows eligible for filtering to be rejected. Planning, cast, and other execution errors can still fail the statement.

Q5: What is the behavioral difference between strict mode and non-strict mode when a char(10) column encounters oversized data?

  • Strict mode enabled: oversized data is filtered out.
  • Strict mode disabled: the ASCII example is truncated to a123456789 before import. The length limit is in bytes. Multi-byte text is checked again after truncation and can still be rejected if it exceeds the byte limit.

Common errors​

  • Too many filtered rows: Inspect the load error and rejected-row counts. Correct the data, column mapping, or target type before increasing the threshold.
  • Routine Load pauses despite a high ratio allowance: Check max_error_number as well as max_filter_ratio, then inspect the pause reason and error log before resuming.
  • Unexpected NULL or shortened strings: Check whether non-strict loading accepted converted values. Use strict mode and validate representative input before loading the full dataset.

See also​