Spark-SQL

Spark-SQL


1.直接通过脚本执行

注意指定使用的资源情况。
spark-sql –executor-cores 1 –executor-memory 2g

2.采用Beeline工具执行(mr用户)

beeline -u jdbc:hive2://localhost:18000 -n mr

HiveQL官方语法文档
https://cwiki.apache.org/confluence/display/Hive/LanguageManual

Example 1

hadoop fs -put /sample_fpgrowth.txt /user/mr/fpgrowth
CREATE EXTERNAL TABLE sample_fpgrowth(
        x1        STRING)
        LOCATION '/user/mr/fpgrowth/';

Example 2

hadoop fs -mkdir /user/mr/airline

hadoop fs -put /international-airline-passengers.csv /user/mr/airline/
CREATE EXTERNAL TABLE international_airline_passenger (
        x1        INT,
        x2        DOUBLE)
row format delimited fields terminated by ',' LOCATION '/user/mr/airline/';

Example3 Hive 0.14以上可用

drop table if exists test_zl;
create table test_zl (x1 INT, x2 DOUBLE, x3 DOUBLE) row format delimited fields terminated by ',';
insert overwrite into table test_zl values (1,2,3); //hive 0.14起支持
insert into table test_zl values( 2,2,3);

Iris数据集

create table iris ( sepal_length  double, sepal_width double, petal_length double, petal_width double, species string) row format delimited fields terminated by ',' LOCATION '/user/mr/iris/';

Titanic数据集

create table titanic_train (age int,passenger_class string,sex string,  no_of_siblings_or_spouses_on_board int, no_of_parents_or_children_on_board int, passenger_fare double, survived string) row format delimited fields terminated by ';' LOCATION '/user/mr/titanic_train/';

create table titanic_unlabeled (age int,passenger_class string,sex string,  no_of_siblings_or_spouses_on_board int, no_of_parents_or_children_on_board int, passenger_fare double) row format delimited fields terminated by ',' LOCATION '/user/mr/titanic_test/';

basket数据集

create table basket (basket string) row format delimited fields terminated by ';' LOCATION '/user/mr/basket/';
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值