kyuubi/docs/client/advanced/features/plan_only.md
Cheng Pan 96498844d3
[KYUUBI #6239] Rename beeline to kyuubi-beeline
# 🔍 Description

Discussion in mailing thread: https://lists.apache.org/thread/tnmz71o3rypy7qvs3899p3jkkq4xqb4r

I propose to rename the `bin/beeline` to `bin/kyuubi-beeline`, while for compatibility, we may still want to keep the alias `bin/beeline` for a while.

In a real Hadoop cluster, it’s likely to add `$HIVE_HOME/bin`, `$SPARK_HOME/bin`, `$KYUUBI_HOME/bin` to the `$PATH`, at the current state, when performing `beeline`, which one is called depends on the declaration order.

It does not matter for Spark’s `bin/beeline` because it’s a vanilla Hive BeeLine, but in Kyuubi, we have made some improvements based on vanilla Hive BeeLine, so the behavior is not exactly same as Hive’s BeeLine.

An identical name would solve this problem. And I saw some vendors[1] who shippes Kyuubi already have done the same thing.

[1] https://help.aliyun.com/zh/emr/emr-on-ecs/user-guide/connect-to-kyuubi

## Types of changes 🔖

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

Manual test.

```
$ bin/beeline -u 'jdbc:kyuubi://0.0.0.0:10009/'
Warning: beeline is deprecated and will be removed in the future, please use kyuubi-beeline instead.
Connecting to jdbc:kyuubi://0.0.0.0:10009/
Connected to: Spark SQL (version 3.4.1)
Driver: Kyuubi Project Hive JDBC Client (version 1.10.0-SNAPSHOT)
Beeline version 1.10.0-SNAPSHOT by Apache Kyuubi
0: jdbc:kyuubi://0.0.0.0:10009/>
```

```
$ bin/kyuubi-beeline -u 'jdbc:kyuubi://0.0.0.0:10009/'
Connecting to jdbc:kyuubi://0.0.0.0:10009/
Connected to: Spark SQL (version 3.4.1)
Driver: Kyuubi Project Hive JDBC Client (version 1.10.0-SNAPSHOT)
Beeline version 1.10.0-SNAPSHOT by Apache Kyuubi
0: jdbc:kyuubi://0.0.0.0:10009/>
```

---

# Checklist 📝

- [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

**Be nice. Be informative.**

Closes #6239 from pan3793/kyuubi-beeline.

Closes #6239

cec8f56e2 [Cheng Pan] docs
b3446baf1 [Cheng Pan] docs
46a115077 [Cheng Pan] Remove `bin/beeline` to `bin/kyuubi-beeline`

Authored-by: Cheng Pan <chengpan@apache.org>
Signed-off-by: Cheng Pan <chengpan@apache.org>
2024-04-03 18:35:38 +08:00

4.1 KiB

Plan Only Execution Mode

Plan only execution mode currently only supports spark and flink engine.

Configure the kyuubi.operation.plan.only.mode parameter, the value can be 'parse', 'analyze', 'optimize', 'optimize_with_stats', 'physical', 'execution', or 'none', when it is 'none', indicate to the statement will be fully executed, otherwise only way without executing the query. Different engines currently support different modes, the spark engine supports all modes, and the flink engine supports 'parse', 'physical', and 'execution', other engines do not support plan-only mode currently, and supports application-level and session-level parameter settings, which are used in the following ways.

Application-level parameter setting

You can add parameters to the URL when establishing a JDBC connection, the parameter is kyuubi.operation.plan.only.mode=parse/analyze/optimize. JDBC URLs have the following format:

jdbc:kyuubi://<host>:<port>/<dbName>;<sessionVars>?kyuubi.operation.plan.only.mode=parse/analyze/optimize/optimize_with_stats/physical/execution/none;<kyuubiConfs>#<[spark|hive]Vars>

Refer to hive_jdbc doc for details of others parameters

Example:

Using kyuubi-beeline to connect to the local service, the Shell command is:

kyuubi-beeline -u 'jdbc:kyuubi://0.0.0.0:10009/default?kyuubi.operation.plan.only.mode=parse' -n {user_name}

Running the following SQL:

SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id

The results are as follows:

# SQL:
0: jdbc:kyuubi://0.0.0.0:10009/default> SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id;

#Result:
+----------------------------------------------------+
|                        plan                        |
+----------------------------------------------------+
| 'Project [*]
+- 'Join LeftOuter, ('t1.id = 't2.id)
   :- 'UnresolvedRelation [t1], [], false
   +- 'UnresolvedRelation [t2], [], false
 |
+----------------------------------------------------+
1 row selected (3.008 seconds)
0: jdbc:kyuubi://0.0.0.0:10009/default>

Session-level parameter setting

You can also set the kyuubi.operation.plan.only.mode parameter by executing the set command after the connection has been established

kyuubi-beeline -u 'jdbc:kyuubi://0.0.0.0:10009/default' -n {user_name}

Running the following SQL:

set kyuubi.operation.plan.only.mode=parse;
SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id

The results are as follows:

#set command:
0: jdbc:kyuubi://0.0.0.0:10009/default> set kyuubi.operation.plan.only.mode=parse;

#set command result:
+----------------------------------+--------+
|               key                | value  |
+----------------------------------+--------+
| kyuubi.operation.plan.only.mode  | parse  |
+----------------------------------+--------+
1 row selected (0.568 seconds)

#execute SQL:
0: jdbc:kyuubi://0.0.0.0:10009/default> SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id;

# SQL result:
+----------------------------------------------------+
|                        plan                        |
+----------------------------------------------------+
| 'Project [*]
+- 'Join LeftOuter, ('t1.id = 't2.id)
   :- 'UnresolvedRelation [t1], [], false
   +- 'UnresolvedRelation [t2], [], false
 |
+----------------------------------------------------+
1 row selected (0.404 seconds)
0: jdbc:kyuubi://0.0.0.0:10009/default>