You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ul...@apache.org on 2021/12/01 08:00:37 UTC

[incubator-kyuubi] branch zorder-docs created (now 62483a8)

This is an automated email from the ASF dual-hosted git repository.

ulyssesyou pushed a change to branch zorder-docs
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git.


      at 62483a8  docs

This branch includes the following new commits:

     new 62483a8  docs

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[incubator-kyuubi] 01/01: docs

Posted by ul...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ulyssesyou pushed a commit to branch zorder-docs
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git

commit 62483a88ea88ca45a0723d61ab42dae41107d5db
Author: ulysses-you <ul...@gmail.com>
AuthorDate: Wed Dec 1 16:00:23 2021 +0800

    docs
---
 docs/imgs/extension/zorder-workflow.png | Bin 0 -> 49985 bytes
 docs/sql/index.rst                      |   1 +
 docs/sql/z-order-introduction.md        | 110 ++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+)

diff --git a/docs/imgs/extension/zorder-workflow.png b/docs/imgs/extension/zorder-workflow.png
new file mode 100644
index 0000000..f38a286
Binary files /dev/null and b/docs/imgs/extension/zorder-workflow.png differ
diff --git a/docs/sql/index.rst b/docs/sql/index.rst
index b8c894b..a3a89e2 100644
--- a/docs/sql/index.rst
+++ b/docs/sql/index.rst
@@ -27,5 +27,6 @@ This part describes the use of the SQL References in Kyuubi, including lists of
 
     rules
     functions
+    z-order-introduction
     z-order-benchmark
 
diff --git a/docs/sql/z-order-introduction.md b/docs/sql/z-order-introduction.md
new file mode 100644
index 0000000..b787c2b
--- /dev/null
+++ b/docs/sql/z-order-introduction.md
@@ -0,0 +1,110 @@
+<!--
+ - Licensed to the Apache Software Foundation (ASF) under one or more
+ - contributor license agreements.  See the NOTICE file distributed with
+ - this work for additional information regarding copyright ownership.
+ - The ASF licenses this file to You under the Apache License, Version 2.0
+ - (the "License"); you may not use this file except in compliance with
+ - the License.  You may obtain a copy of the License at
+ -
+ -   http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing, software
+ - distributed under the License is distributed on an "AS IS" BASIS,
+ - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ - See the License for the specific language governing permissions and
+ - limitations under the License.
+ -->
+
+<!-- DO NOT MODIFY THIS FILE DIRECTLY, IT IS AUTO GENERATED BY [org.apache.kyuubi.engine.spark.udf.KyuubiDefinedFunctionSuite] -->
+
+<div align=center>
+
+![](../imgs/kyuubi_logo.png)
+
+</div>
+
+# Z-order introduction
+
+## introduction
+
+The following picture shows the workflow of z-order.
+
+![](../imgs/extension/zorder-workflow.png)
+
+### Supported table
+
+| Table Format | Supported |
+|--------------|-----------|
+| parquet      |     Y     |
+| orc          |     Y     |
+| json         |     N     |
+| csv          |     N     |
+| text         |     N     |
+
+### Supported column data type
+
+| Column Data Type | Supported |
+|------------------|-----------|
+| byte             |     Y     |
+| short            |     Y     |
+| int              |     Y     |
+| long             |     Y     |
+| float            |     Y     |
+| double           |     Y     |
+| boolean          |     Y     |
+| string           |     Y     |
+| decimal          |     Y     |
+| date             |     Y     |
+| timestamp        |     Y     |
+| array            |     N     |
+| map              |     N     |
+| struct           |     N     |
+| udt              |     N     |
+
+## How to use
+
+This feature is inside Kyuubi extension, so you should apply the extension to Spark by following steps.
+
+- add extension jar: `copy $KYUUBI_HOME/extension/kyuubi-extension-spark-3-1* $SPARK_HOME/jars/`
+- add config into `spark-defaults.conf`: `spark.sql.extensions=org.apache.kyuubi.sql.KyuubiSparkSQLExtension`
+
+Due to the extension, z-order only works with Spark-3.1 and higher version.
+
+### Optimize history data
+
+If you want to optimize the history data of a table, the `OPTIMIZE ...` syntax is good to go. Due to Spark SQL doesn't support read and overwrite same datasource table, the syntax can only support to optimize Hive table.
+
+#### Syntax
+```sql
+OPTIMIZE table_name [WHERE predicate] ZORDER BY col_name1 [, ...]
+```
+
+Note that, the `predicate` only supports partition column.
+
+#### Examples
+```sql
+OPTIMIZE t1 ZORDER BY c3;
+
+OPTIMIZE t1 ZORDER BY c1,c2;
+
+OPTIMIZE t1 WHERE day = '2021-12-01' ZORDER BY c1,c2;
+```
+
+### Optimize incremental data
+
+Kyuubi supports optimize a table automatically for incremental data. e.g., time partitioned table. The only things you need to do is adding Kyuubi properties into the target table properties:
+```sql
+ALTER TABLE t1 SET TBLPROPERTIES('kyuubi.zorder.enabled'='true','kyuubi.zorder.cols'='c1,c2');
+```
+- the key `kyuubi.zorder.enabled` decide if the table allows Kyuubi to optimize by z-order.
+- the key `kyuubi.zorder.cols` decide which columns are used to optimize by z-order.
+
+Kyuubi will detect the properties and optimize SQL using z-order during SQL compilation, so you can enjoy z-order with all writing table command like:
+
+```sql
+INSERT INTO TABLE t1 PARTITION() ...;
+
+INSERT OVERWRITE TABLE t1 PARTITION() ...;
+
+CREATE TABLE t1 AS SELECT ...;
+```