This section describes how to use Spark SQL. You can submit a Spark SQL statement to query and analyze data on the MRS management console page. To submit multiple statements, separate them from each other using semicolons (;).
When entering Spark SQL statements, ensure that they have no more than 10,000 characters.
CREATE [EXTERNAL] TABLE [IF NOT EXISTS] table_name [(col_name data_type [COMMENT col_comment], ...)] [COMMENT table_comment] [PARTITIONED BY (col_name data_type [COMMENT col_comment], ...)] [CLUSTERED BY (col_name, col_name, ...) [SORTED BY (col_name [ASC|DESC], ...)] INTO num_buckets BUCKETS] [ROW FORMAT row_format] [STORED AS file_format] [LOCATION hdfs_-path];
Use either of the following methods to create a table:
create external table src_data(line string) row format delimited fields terminated by '\\n' stored as text file location '/user/guest/input/';
create table src_data1 (eid int, name String, salary String, destination String) row format delimited fields terminated by ',' ;
load data in path '/tttt/test.txt' into table src_data1;
The data from OBS cannot be loaded to the created tables in method 2.
SELECT col_name FROM table_name;
select * from src_data;
DROP TABLE [IF EXISTS] table_name;
drop table src_data;
After submitting Spark SQL statements, you can check whether the execution is successful in Last Execution Result and view detailed execution results in Last Query Result Set.