Skip to content
Merged
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
12 changes: 12 additions & 0 deletions docs/src/main/sphinx/connector/iceberg.md
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,18 @@ CREATE TABLE example.customers.orders (
WITH (sorted_by = ARRAY['order_date'])
```

You can explicitly configure sort directions or null ordering in the following way:

```
CREATE TABLE example.customers.orders (
order_id BIGINT,
order_date DATE,
account_number BIGINT,
customer VARCHAR,
country VARCHAR)
WITH (sorted_by = ARRAY['order_date DESC NULLS FIRST', 'order_id ASC NULLS LAST'])
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this SQL in my local machine.

trino> CREATE TABLE iceberg.default.orders (
    ->     order_id BIGINT,
    ->     order_date DATE,
    ->     account_number BIGINT,
    ->     customer VARCHAR,
    ->     country VARCHAR)
    -> WITH (sorted_by = ARRAY['order_date DESC NULLS FIRST', 'order_id ASC NULLS LAST'])
    -> ;
CREATE TABLE
trino> 
$ hdfs dfs -cat /user/hive/warehouse/orders-5fae815b97d54add91c0100370e56f0c/metadata/00000-cf46fb4f-226b-42dc-b640-c14d9e000c09.metadata.json
...
  "schemas" : [ {
    "type" : "struct",
    "schema-id" : 0,
    "fields" : [ {
      "id" : 1,
      "name" : "order_id",
      "required" : false,
      "type" : "long"
    }, {
      "id" : 2,
      "name" : "order_date",
      "required" : false,
      "type" : "date"
    }, {
      "id" : 3,
      "name" : "account_number",
      "required" : false,
      "type" : "long"
    }, {
      "id" : 4,
      "name" : "customer",
      "required" : false,
      "type" : "string"
    }, {
      "id" : 5,
      "name" : "country",
      "required" : false,
      "type" : "string"
    } ]
  } ],
...
  "default-sort-order-id" : 1,
  "sort-orders" : [ {
    "order-id" : 1,
    "fields" : [ {
      "transform" : "identity",
      "source-id" : 2,
      "direction" : "desc",
      "null-order" : "nulls-first"
    }, {
      "transform" : "identity",
      "source-id" : 1,
      "direction" : "asc",
      "null-order" : "nulls-last"
    } ]
  } ],


Sorting can be combined with partitioning on the same column. For example:

```
Expand Down
Loading