Zoltán Borók-Nagy created IMPALA-15795:
------------------------------------------

             Summary: Impala ignores the write.metadata.metrics properties of 
Iceberg tables
                 Key: IMPALA-15795
                 URL: https://issues.apache.org/jira/browse/IMPALA-15795
             Project: IMPALA
          Issue Type: Bug
          Components: Catalog, Backend
            Reporter: Zoltán Borók-Nagy


Iceberg's writers choose the column metrics of data files by table properties 
({{MetricsConfig}}):
* {{write.metadata.metrics.default}} is {{truncate(16)}} by default: string 
bounds are truncated to 16 characters and binary bounds to 16 bytes, and the 
upper bound is incremented.
* {{write.metadata.metrics.column.<name>}} sets {{none}}, {{counts}}, 
{{truncate(length)}} or {{full}} for one column.
* If the default isn't set, only the first 
{{write.metadata.metrics.max-inferred-column-defaults}} columns, 100 by 
default, get metrics.

Impala's DML (INSERT, UPDATE, DELETE, MERGE, OPTIMIZE) ignores these properties 
and always writes full metrics for every column: counts plus untruncated 
minimum and maximum values. Only ALTER TABLE CONVERT TO ICEBERG takes them into 
account, through Iceberg's {{TableMigrationUtil}}. So:
* String bounds are as long as the values. E.g. a STRING column of 100 KB JSON 
documents adds about 200 KB to the manifest entry of every data file, which 
every engine reads during planning. Impala doesn't write Parquet statistics 
larger than 4 KB into the file footers, but there is no such limit for the 
Iceberg metrics.
* Every column of a wide table gets metrics.
* Setting {{none}} or {{counts}} doesn't keep the values of a column out of the 
table metadata.
* Iceberg's {{PositionDeleteWriter}} writes no value or null counts for 
{{file_path}} and {{pos}}, and writes their bounds only if the delete file 
refers to a single data file. Impala writes counts and bounds for both columns 
of every position delete file.

{code:sql}
create table str_t (s string) stored as iceberg
tblproperties ('write.metadata.metrics.default'='none');
insert into str_t values (repeat('x', 1000)), (repeat('y', 1000));
select length(readable_metrics.s.lower_bound), 
length(readable_metrics.s.upper_bound)
from str_t.`files`;
-- 1000  1000
-- expected no bounds, and 16 characters without the table property
{code}

Impala could build a {{MetricsConfig}} for the table and drop or truncate the 
metrics accordingly when it creates the data files and delete files in 
{{IcebergCatalogOpExecutor}}. Truncating already in the backend would also 
avoid sending the long values to the coordinator and catalogd.

Found while comparing the Iceberg metrics written by master (19731aa580) with 
Iceberg 1.11.0.

---------------------------------------------------------------------------------------------



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to