Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class TestSplitPruning
"float_nan",
"float_inf",
"no_stats",
"nested_fields",
"timestamp",
"test_partitioning",
"parquet_struct_statistics",
Expand Down Expand Up @@ -358,6 +359,32 @@ public void testParquetStatisticsPruning()
testCountQuery("SELECT count(*) FROM parquet_struct_statistics WHERE row = ROW(2, 'b')", 3, 9);
}

@Test
public void testPrimitiveFieldsInsideRowColumnPruning()
{
assertResultAndSplitCount(
"SELECT grandparent.parent1.child1 FROM nested_fields WHERE id > 6",
Set.of(70.99, 80.99, 90.99, 100.99),
1);

assertResultAndSplitCount(
"SELECT grandparent.parent1.child1 FROM nested_fields WHERE id > 10",
Set.of(),
0);

// TODO pruning does not work on primitive fields inside a struct, expected splits should be 1 after file pruning (https://github.com/trinodb/trino/issues/17164)
assertResultAndSplitCount(
"SELECT grandparent.parent1.child1 FROM nested_fields WHERE parent.child1 > 600",
Set.of(70.99, 80.99, 90.99, 100.99),
2);

// TODO pruning does not work on primitive fields inside a struct, expected splits should be 0 after file pruning (https://github.com/trinodb/trino/issues/17164)
assertResultAndSplitCount(
"SELECT grandparent.parent1.child1 FROM nested_fields WHERE parent.child1 > 1000",
Set.of(),
2);
}

@Test
public void testJsonStatisticsPruningUppercaseColumn()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Data generated using Databricks 10.4 LTS:

```sql
CREATE TABLE nested_fields (id INT, parent STRUCT<child1: BIGINT, child2: STRING>, grandparent STRUCT<parent1 STRUCT<child1: DOUBLE, child2: BOOLEAN>, parent2 STRUCT<child1: DATE>>) USING DELTA LOCATION 's3://starburst-test/nested_fields';

INSERT INTO nested_fields VALUES
(1, struct('100', 'INDIA'), struct(struct(10.99, true), struct('2023-01-01'))),
(2, struct('200', 'POLAND'), struct(struct(20.99, false), struct('2023-02-01'))),
(3, struct('300', 'USA'), struct(struct(30.99, true), struct('2023-03-01'))),
(4, struct('400', 'AUSTRIA'), struct(struct(40.99, false), struct('2023-04-01'))),
(5, struct('500', 'JAPAN'), struct(struct(50.99, true), struct('2023-05-01'))),
(6, struct('600', 'UK'), struct(struct(60.99, false), struct('2023-06-01'))),
(7, struct('700', 'FRANCE'), struct(struct(70.99, true), struct('2023-07-01'))),
(8, struct('800', 'BRAZIL'), struct(struct(80.99, false), struct('2023-08-01'))),
(9, struct('900', 'NAMIBIA'), struct(struct(90.99, true), struct('2023-09-01'))),
(10, struct('1000', 'RSA'), struct(struct(100.99, false), struct('2023-10-01')));
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"commitInfo":{"timestamp":1681993589387,"userId":"7499806201888255","userName":"[email protected]","operation":"CREATE TABLE","operationParameters":{"isManaged":"false","description":null,"partitionBy":"[]","properties":"{}"},"notebook":{"notebookId":"4432842678029071"},"clusterId":"1118-145353-2w37w56t","isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{},"engineInfo":"Databricks-Runtime/10.4.x-scala2.12","txnId":"63491529-eec9-485b-9aca-662bac90be67"}}
{"protocol":{"minReaderVersion":1,"minWriterVersion":2}}
{"metaData":{"id":"735e2c32-06a1-4c03-a5a8-5d0b92c58f85","format":{"provider":"parquet","options":{}},"schemaString":"{\"type\":\"struct\",\"fields\":[{\"name\":\"id\",\"type\":\"integer\",\"nullable\":true,\"metadata\":{}},{\"name\":\"parent\",\"type\":{\"type\":\"struct\",\"fields\":[{\"name\":\"child1\",\"type\":\"long\",\"nullable\":true,\"metadata\":{}},{\"name\":\"child2\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}}]},\"nullable\":true,\"metadata\":{}},{\"name\":\"grandparent\",\"type\":{\"type\":\"struct\",\"fields\":[{\"name\":\"parent1\",\"type\":{\"type\":\"struct\",\"fields\":[{\"name\":\"child1\",\"type\":\"double\",\"nullable\":true,\"metadata\":{}},{\"name\":\"child2\",\"type\":\"boolean\",\"nullable\":true,\"metadata\":{}}]},\"nullable\":true,\"metadata\":{}},{\"name\":\"parent2\",\"type\":{\"type\":\"struct\",\"fields\":[{\"name\":\"child1\",\"type\":\"date\",\"nullable\":true,\"metadata\":{}}]},\"nullable\":true,\"metadata\":{}}]},\"nullable\":true,\"metadata\":{}}]}","partitionColumns":[],"configuration":{},"createdTime":1681993589155}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"commitInfo":{"timestamp":1681993595946,"userId":"7499806201888255","userName":"[email protected]","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"4432842678029071"},"clusterId":"1118-145353-2w37w56t","readVersion":0,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"2","numOutputRows":"10","numOutputBytes":"4731"},"engineInfo":"Databricks-Runtime/10.4.x-scala2.12","txnId":"cc74cc50-8684-4179-bddc-248ef4350d7c"}}
{"add":{"path":"part-00000-8e3f6979-c368-4f48-b389-9b4dbf46de93-c000.snappy.parquet","partitionValues":{},"size":2366,"modificationTime":1681993596000,"dataChange":true,"stats":"{\"numRecords\":5,\"minValues\":{\"id\":1,\"parent\":{\"child1\":100,\"child2\":\"AUSTRIA\"},\"grandparent\":{\"parent1\":{\"child1\":10.99},\"parent2\":{\"child1\":\"2023-01-01\"}}},\"maxValues\":{\"id\":5,\"parent\":{\"child1\":500,\"child2\":\"USA\"},\"grandparent\":{\"parent1\":{\"child1\":50.99},\"parent2\":{\"child1\":\"2023-05-01\"}}},\"nullCount\":{\"id\":0,\"parent\":{\"child1\":0,\"child2\":0},\"grandparent\":{\"parent1\":{\"child1\":0,\"child2\":0},\"parent2\":{\"child1\":0}}}}","tags":{"INSERTION_TIME":"1681993596000000","OPTIMIZE_TARGET_SIZE":"268435456"}}}
{"add":{"path":"part-00001-dd006b0f-93c6-4f87-801f-a8b7153a72ae-c000.snappy.parquet","partitionValues":{},"size":2365,"modificationTime":1681993596000,"dataChange":true,"stats":"{\"numRecords\":5,\"minValues\":{\"id\":6,\"parent\":{\"child1\":600,\"child2\":\"BRAZIL\"},\"grandparent\":{\"parent1\":{\"child1\":60.99},\"parent2\":{\"child1\":\"2023-06-01\"}}},\"maxValues\":{\"id\":10,\"parent\":{\"child1\":1000,\"child2\":\"UK\"},\"grandparent\":{\"parent1\":{\"child1\":100.99},\"parent2\":{\"child1\":\"2023-10-01\"}}},\"nullCount\":{\"id\":0,\"parent\":{\"child1\":0,\"child2\":0},\"grandparent\":{\"parent1\":{\"child1\":0,\"child2\":0},\"parent2\":{\"child1\":0}}}}","tags":{"INSERTION_TIME":"1681993596000001","OPTIMIZE_TARGET_SIZE":"268435456"}}}
Binary file not shown.
Binary file not shown.