You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/07/27 10:16:03 UTC

[GitHub] [iceberg] openinx commented on issue #2874: how to write order by sql

openinx commented on issue #2874:
URL: https://github.com/apache/iceberg/issues/2874#issuecomment-887390581


   @julianjsynnex , the correct way to create a spark table with sort order columns is: 
   
   Step.1  start a spark-sql:
   
   ```bash
   ./bin/spark-sql --jars /Users/openinx/test/apache-iceberg-0.12.0-1.0.0/spark3-runtime/build/libs/iceberg-spark3-runtime-0.12.0-1.0.0.jar \
       --conf spark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions \
       --conf spark.sql.catalog.local=org.apache.iceberg.spark.SparkCatalog \
       --conf spark.sql.catalog.local.type=hadoop \
       --conf spark.sql.catalog.local.warehouse=file:///Users/openinx/test/spark-warehouse
   ```
   
   Step.2  create table
   
   ```sql
   CREATE TABLE local.default.sample (
       id   BIGINT,
       data STRING
   ) USING iceberg ;
   ```
   
   Step.3 Alter the table with sort-order columns: 
   
   ```sql
   ALTER TABLE local.default.sample WRITE ORDERED BY (data, id);
   ```
   
   Finally,  you can see the sort-order specification in `sample` table's metadata: 
   
   ```json
   "default-sort-order-id" : 1,
     "sort-orders" : [ {
       "order-id" : 0,
       "fields" : [ ]
     }, {
       "order-id" : 1,
       "fields" : [ {
         "transform" : "identity",
         "source-id" : 2,
         "direction" : "asc",
         "null-order" : "nulls-first"
       }, {
         "transform" : "identity",
         "source-id" : 1,
         "direction" : "asc",
         "null-order" : "nulls-first"
       } ]
     } ],
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org