DSS用户测试样例的目的是为平台新用户提供一组测试样例,用于熟悉DSS的常见操作,并验证DSS平台的正确性
进入“数据库”页面,点击“+”,依次输入表信息、表结构和分区信息即可创建数据库表:
通过以上流程,分别创建部门表dept、员工表emp和分区员工表emp_partition,建表语句如下:
create external table if not exists default.dept(
deptno int,
dname string,
loc int
)
row format delimited fields terminated by '\t';
create external table if not exists default.emp(
empno int,
ename string,
job string,
mgr int,
hiredate string,
sal double,
comm double,
deptno int
)
row format delimited fields terminated by '\t';
create table if not exists emp_partition(
empno int,
ename string,
job string,
mgr int,
hiredate string,
sal double,
comm double,
deptno int
)
partitioned by (month string)
row format delimited fields terminated by '\t';
导入数据
目前需要通过后台手动批量导入数据,可以通过insert方法从页面插入数据
load data local inpath 'dept.txt' into table default.dept;
load data local inpath 'emp.txt' into table default.emp;
load data local inpath 'emp1.txt' into table default.emp_partition;
load data local inpath 'emp2.txt' into table default.emp_partition;
load data local inpath 'emp2.txt' into table default.emp_partition;
其它数据按照上述语句导入,样例数据文件路径在:examples\ch3
select * from dept;
select * from emp
left join dept
on emp.deptno = dept.deptno;
select dept.dname, avg(sal) as avg_salary
from emp left join dept
on emp.deptno = dept.deptno
group by dept.dname;
select ename, job,sal,
rank() over(partition by job order by sal desc) sal_rank
from emp;
show partitions emp_partition;
select * from emp_partition where month='202001';
select * from emp_partition where month='202001'
union
select * from emp_partition where month='202002'
union
select * from emp_partition where month='202003'
进入 Scriptis 页面后,右键目录路径上传jar包:
测试样例jar包在 examples\ch3\rename.jar
进入“UDF函数”选项(如1),右击“个人函数”目录,选择“新增函数”:
输入函数名称、选择jar包、并填写注册格式、输入输出格式即可创建函数:
获得的函数如下:
完成函数注册后,可进入工作空间页面创建.hql文件使用函数:
select deptno,ename, rename(ename) as new_name
from emp;