Connect to Lakehouse Using the Command Line Client

This article describes how to install, configure, and use the sqlline-based Lakehouse command line client.


Prerequisites

Before using the client, ensure the following conditions are met:

  1. Your device has Java 8 or a higher version installed
  2. You have registered an account on the Singdata platform and created a Lakehouse service instance
  3. You have created a workspace for connection access
  4. The user identity using the client has been added to the workspace and authorized for access

Installing the Client

The Lakehouse command line client is a secondary development of the open-source SQL Line project. Follow these steps to install and configure the client:

  1. Download the client installation package sqlline_cz.tar.gz from the public network or obtain it from Singdata staff
  2. Unzip the installation package file to get the client tool's executable and configuration files:

tar -zxvf sqlline_cz.tar.gz

Extracted contents:

sqlline_cz/ β”œβ”€β”€ example.properties β”œβ”€β”€ log4j.properties β”œβ”€β”€ setup.sh β”œβ”€β”€ sqlline └── sqlline-2.13.0-SNAPSHOT-jar-with-dependencies.jar


Initialize Connection Environment

  1. Enter the working directory:

cd sqlline_cz

  1. Initialize the connection environment, downloading the latest JDBC driver:

sh setup.sh

If the setup script fails to download, manually download the JDBC driver and place it in the sqlline_cz directory:


Configure Client Connection

Method 1: Specify Connection Parameters via Command Line

sh sqlline -d com.clickzetta.client.jdbc.ClickZettaDriver \ -u "jdbc:clickzetta://<instance>.<region>.api.clickzetta.com/<workspace>?schema=<schema>&vcluster=<vcluster>" \ -n <user_name> \ -p <password>

JDBC URL format:

jdbc:clickzetta://<instance_name>.<region_id>.api.clickzetta.com/<workspace_name>?schema=<schema_name>&vcluster=<vcluster_name>

Parameter descriptions:

ParameterDescription
-dJDBC driver class name, fixed as com.clickzetta.client.jdbc.ClickZettaDriver
-uJDBC connection URL, see JDBC Driver for full format
-nWorkspace member username
-pWorkspace member password
schemaSpecifies the Schema to connect to, required
vclusterVirtual Cluster to use, required

Example:

sh sqlline -d com.clickzetta.client.jdbc.ClickZettaDriver \ -u "jdbc:clickzetta://my_instance.cn-shanghai-alicloud.api.clickzetta.com/my_workspace?schema=public&vcluster=DEFAULT" \ -n data_user \ -p your_password

Method 2: Specify Configuration File via Command Line

  1. Modify the configuration file template example.properties:

url=jdbc:clickzetta://<instance>.<region>.api.clickzetta.com/<workspace>?schema=<schema>&vcluster=<vcluster> driver=com.clickzetta.client.jdbc.ClickZettaDriver user=<your_user_name> password=<your_password>

  1. Connect using the configuration file:

sh sqlline properties test.properties

After connecting, use the !properties command to quickly switch to another configuration file within the session:

0: jdbc:clickzetta://xxxx.api.clickzetta.com> !properties test.properties.1 1: jdbc:clickzetta://yyyy.api.clickzetta.com>


Running SQL Commands

After a successful connection, you can execute Lakehouse SQL commands in the command line client:

-- Switch Virtual Cluster and Schema use vcluster DEFAULT; use schema nyc_taxi_data; -- View tables in the current Schema show tables; -- Query data select * from fhv_trips_staging limit 10;


Exit Client

!quit


Enable Debug Logging

Enable debug mode by setting an environment variable to output log files for troubleshooting:

export SQLLINE_DEBUG_ENABLE=TRUE