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 2023/02/20 02:11:05 UTC

[kyuubi] branch master updated: [KYUUBI #4345] Add the doc of kyuubi trino server

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

ulyssesyou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new dec432713 [KYUUBI #4345] Add the doc of kyuubi trino server
dec432713 is described below

commit dec432713107cd52eb5fef9be3e98a02e11e5276
Author: odone <od...@gmail.com>
AuthorDate: Mon Feb 20 10:10:58 2023 +0800

    [KYUUBI #4345] Add the doc of kyuubi trino server
    
    https://github.com/apache/kyuubi/issues/3901
    ### _Why are the changes needed?_
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [ ] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #4345 from iodone/trino-server-dock.
    
    Closes #4345
    
    6f8e3149 [odone] add the doc of kyuubi trino server
    
    Authored-by: odone <od...@gmail.com>
    Signed-off-by: ulyssesyou <ul...@apache.org>
---
 docs/client/cli/index.rst      |  1 +
 docs/client/cli/trino_cli.md   | 88 ++++++++++++++++++++++++++++++++++++++++
 docs/client/jdbc/index.rst     |  1 +
 docs/client/jdbc/trino_jdbc.md | 92 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 182 insertions(+)

diff --git a/docs/client/cli/index.rst b/docs/client/cli/index.rst
index 61be9ad8c..19122ced4 100644
--- a/docs/client/cli/index.rst
+++ b/docs/client/cli/index.rst
@@ -21,3 +21,4 @@ Command Line Interface(CLI)s
 
     kyuubi_beeline
     hive_beeline
+    trino_cli
diff --git a/docs/client/cli/trino_cli.md b/docs/client/cli/trino_cli.md
new file mode 100644
index 000000000..68ebd8300
--- /dev/null
+++ b/docs/client/cli/trino_cli.md
@@ -0,0 +1,88 @@
+<!--
+- 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.
+-->
+
+# Trino command line interface
+
+The Trino CLI provides a terminal-based, interactive shell for running queries. We can use it to connect Kyuubi server now.
+
+## Start Kyuubi Trino Server
+
+First we should configure the trino protocol and the service port in the `kyuubi.conf`
+
+```
+kyuubi.frontend.protocols TRINO
+kyuubi.frontend.trino.bind.port 10999 #default port
+```
+
+## Install
+
+Download [trino-cli-363-executable.jar](https://repo1.maven.org/maven2/io/trino/trino-jdbc/363/trino-jdbc-363.jar), rename it to `trino`, make it executable with `chmod +x`, and run it to show the version of the CLI:
+
+```
+wget https://repo1.maven.org/maven2/io/trino/trino-jdbc/363/trino-jdbc-363.jar
+mv trino-jdbc-363.jar trino
+chmod +x trino
+./trino --version
+```
+
+## Running the CLI
+
+The minimal command to start the CLI in interactive mode specifies the URL of the kyuubi server with the Trino protocol:
+
+```
+./trino --server http://localhost:10999
+```
+
+If successful, you will get a prompt to execute commands. Use the help command to see a list of supported commands. Use the clear command to clear the terminal. To stop and exit the CLI, run exit or quit.:
+
+```
+trino> help
+
+Supported commands:
+QUIT
+EXIT
+CLEAR
+EXPLAIN [ ( option [, ...] ) ] <query>
+    options: FORMAT { TEXT | GRAPHVIZ | JSON }
+             TYPE { LOGICAL | DISTRIBUTED | VALIDATE | IO }
+DESCRIBE <table>
+SHOW COLUMNS FROM <table>
+SHOW FUNCTIONS
+SHOW CATALOGS [LIKE <pattern>]
+SHOW SCHEMAS [FROM <catalog>] [LIKE <pattern>]
+SHOW TABLES [FROM <schema>] [LIKE <pattern>]
+USE [<catalog>.]<schema>
+```
+
+You can now run SQL statements. After processing, the CLI will show results and statistics.
+
+```
+trino> select 1;
+ _col0
+-------
+     1
+(1 row)
+
+Query 20230216_125233_00806_examine_6hxus, FINISHED, 1 node
+Splits: 1 total, 1 done (100.00%)
+0.29 [0 rows, 0B] [0 rows/s, 0B/s]
+
+trino>
+```
+
+Many other options are available to further configure the CLI in interactive mode to
+refer https://trino.io/docs/current/client/cli.html#running-the-cli
diff --git a/docs/client/jdbc/index.rst b/docs/client/jdbc/index.rst
index 31871f138..abcd6a452 100644
--- a/docs/client/jdbc/index.rst
+++ b/docs/client/jdbc/index.rst
@@ -22,4 +22,5 @@ JDBC Drivers
     kyuubi_jdbc
     hive_jdbc
     mysql_jdbc
+    trino_jdbc
 
diff --git a/docs/client/jdbc/trino_jdbc.md b/docs/client/jdbc/trino_jdbc.md
new file mode 100644
index 000000000..0f91c4337
--- /dev/null
+++ b/docs/client/jdbc/trino_jdbc.md
@@ -0,0 +1,92 @@
+<!--
+- 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.
+-->
+
+# Trino JDBC Driver
+
+## Instructions
+
+Kyuubi currently supports the Trino connection protocol, so we can use Trino-JDBC to connect to the kyuubi server
+and submit SQL to Spark, Trino and other engines for execution.
+
+## Start Kyuubi Trino Server
+
+First we should configure the trino protocol and the service port in the `kyuubi.conf`
+
+```
+kyuubi.frontend.protocols TRINO
+kyuubi.frontend.trino.bind.port 10999 #default port
+```
+
+## Install Trino JDBC
+
+Download [trino-jdbc-363.jar](https://repo1.maven.org/maven2/io/trino/trino-jdbc/363/trino-jdbc-363.jar) and add it to the classpath of your Java application.
+
+The driver is also available from Maven Central:
+
+```xml
+<dependency>
+    <groupId>io.trino</groupId>
+    <artifactId>trino-jdbc</artifactId>
+    <version>363</version>
+</dependency>
+```
+
+## JDBC URL
+
+When your driver is loaded, registered and configured, you are ready to connect to Trino from your application. The following JDBC URL formats are supported:
+
+```
+jdbc:trino://host:port
+```
+
+Trino JDBC example
+
+```java
+String trinoHost = "localhost";
+String trinoPort = "10999";
+String trinoUser = "default";
+String trinoPassword = null;
+Connection connection = null;
+ResultSet rs = null;
+
+try {
+    // Create the connection using the JDBC URL
+    connection = DriverManager.getConnection("jdbc:trino://" + trinoHost + ":" + trinoPort, trinoUser, trinoPassword);
+
+    // Do whatever you need to do with the connection
+    Statement stmt = connection.createStatement();
+    rs = stmt.executeQuery("SELECT 1");
+
+    while (rs.next()) {
+    // retrieve data from the ResultSet
+    }
+
+} catch (Exception e) {
+    e.printStackTrace();
+} finally {
+    try {
+        // Close the connection when you're done with it
+        if (rs != null) rs.close();
+        if (connection != null) connection.close();
+    } catch (Exception e) {
+        e.printStackTrace();
+    }
+} 
+```
+
+The configuration of the connection parameters can be found in the official trino documentation at: https://trino.io/docs/current/client/jdbc.html#connection-parameters
+