This topic describes how to use Lindorm Distributed Processing System (LDPS) to read and write data by executing SQL statements.
Prerequisites
LindormTable is activated for your Lindorm instance. For more information, see Create an instance.
LDPS is activated for your Lindorm instance. For more information, see Activate LDPS and modify the configurations.
The IP address of your client is added to the whitelist of your Lindorm instance. For more information, see Configure whitelists.
Step 1: Make preparations
Download the Spark release package.
Decompress the downloaded Spark release package.
Set the environment variable SPARK_HOME to the path to which the package is decompressed.
export SPARK_HOME=/path/to/spark/;
Configure parameters in the following configuration file:
$SPARK_HOME/conf/beeline.conf
.endpoint: Set this parameter to the LDPS endpoint for JDBC. For more information about how to obtain the endpoint, see View the endpoints of LDPS.
user: Set this parameter to the password that is used to access LindormTable
password: Set this parameter to the password that is used to access LindormTable.
shareResource: Specify whether the Spark resources are shared by multiple interactive sessions. The default value of this parameter is
true
.
Activate Hive Metastore. For more information, see Activate Hive Metastore.
Step 2: Write data to a table
Go to the
$SPARK_HOME/bin
path and run the./beeline
command.In the interactive session, execute the following SQL statements:
-- Create a table. CREATE TABLE test (id INT, name STRING); -- Insert data into the table. INSERT INTO test VALUES (0, 'Jay'), (1, 'Edison');
Step 3: Read data from a table
Run the
/bin/beeline
command.In the interactive session, execute the following SQL statement:
SELECT id, name FROM test;