文档

MaxCompute数据源建表语句说明

建表语句

假设数据表表名为test_maxcompute_table,那么done表表名为test_maxcompute_table_done。

#1.创建数据表:
CREATE TABLE IF NOT EXISTS test_maxcompute_table
(
  pk_id Bigint ,
  cate_id Bigint ,
  vector_array string 
)
PARTITIONED by 
(
  ds STRING
);

#2.创建数据表分区:
alter table test_maxcompute_table  add if not exists partition (ds="20230423");

#3.创建done表
create table test_maxcompute_table_done (attribute string) partitioned by (ds string);

#4.创建done表分区
alter table test_maxcompute_table_done  add if not exists partition (ds="20230423");


#5.在数据表中插入数据
insert into test_maxcompute_table partition (ds='20230423') select 1,'12345','xxx,xxx,xxx,xx....';

#6.done表中插入数据
insert into table ecom_table_done partition (ds="20230423") select '{"swift_start_timestamp":1682179200}';
说明

引擎支持的MaxCompute 表字段类型有:STRING 、BOOLEAN、DOUBLE、BIGINT、DATETIME;

授权语句

表权限,在配置MaxCompute 数据表时需要登录OpenSearch的账号对该表有相应的权限(describe,select,download,字段的label权限)。

-- 添加账号(该账号为操作引擎实例的账号)
add user ****@aliyun.com;

-- 给该账号赋相应的表权限
GRANT describe,select,download ON TABLE table_xxx TO USER ****@aliyun.com
GRANT describe,select,download ON TABLE table_xxx_done TO USER ****@aliyun.com

-- 由于MaxCompute开启了字段权限校验,导致拉取数据的时候无法访问高权限的字段,表索引build不出来,碰到这种情况需要授权给账号字段级别的访问权限。
-- 给整个Project统一授权
SET LABEL 3 to USER ****@aliyun.com

-- 给单表授权
GRANT LABEL 3 ON TABLE table_xxx(col1, col2) TO ****@aliyun.com

MaxCompute数据源相关参数查找

image

参数

是否必填

说明

数据源类型

选择“MaxCompute”

数据源名称

长度限制为30个字符,有且只能有数字、字母、下划线

project

MaxCompute的数据开发页面可查看

image
说明

如果是标准版模式:

image

需要在项目名后加_dev,比如zy_ts_test >zy_ts_test_dev

accessKeyId

在账号管理下可查看

image

accessKeySecret

table

数据表表名

分区

数据表分区,例如:ds=20230423,ds表示分区名

  • 本页导读 (0)
文档反馈