建表语句
假设数据表表名为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数据源相关参数查找
在左侧导航菜单中选择数据源配置,单击添加数据源,在右侧打开的配置表单中填写以下参数。其中自动索引重建默认选择是。
|
参数 |
是否必填 |
说明 |
|
数据源类型 |
是 |
选择“MaxCompute” |
|
数据源名称 |
是 |
长度限制为30个字符,有且只能有数字、字母、下划线 |
|
project |
是 |
MaxCompute的数据开发页面可查看 在 DataStudio 顶部导航栏左侧的工作空间下拉选择器中,可查看当前所在工作空间名称。 说明
在DataStudio的表管理界面中,通过搜索功能查找目标表,若搜索结果中表名旁显示标准模式标签,则说明该项目为标准模式。 需要在项目名后加_dev,比如zy_ts_test >zy_ts_test_dev |
|
accessKeyId |
是 |
在账号管理下可查看 将鼠标悬停在控制台右上角的用户头像上,在弹出的账户面板中单击 AccessKey 管理。 |
|
accessKeySecret |
是 |
|
|
table |
是 |
数据表表名 |
|
分区 |
是 |
数据表分区,例如:ds=20230423,ds表示分区名 |
该文章对您有帮助吗?