Sentencias de creación de tablas
En este ejemplo, la tabla de datos se llama test_maxcompute_table y su tabla done correspondiente es test_maxcompute_table_done.
#1. Create a data table.
CREATE TABLE IF NOT EXISTS test_maxcompute_table
(
pk_id Bigint ,
cate_id Bigint ,
vector_array string
)
PARTITIONED by
(
ds STRING
);
#2. Create a partition in the data table.
alter table test_maxcompute_table add if not exists partition (ds="20230423");
#3. Create a done table.
create table test_maxcompute_table_done (attribute string) partitioned by (ds string);
#4. Create a partition in the done table.
alter table test_maxcompute_table_done add if not exists partition (ds="20230423");
#5. Insert data into the data table.
insert into test_maxcompute_table partition (ds='20230423') select 1,'12345','xxx,xxx,xxx,xx....';
#6. Insert data into the done table.
insert into table test_maxcompute_table_done partition (ds="20230423") select '{"swift_start_timestamp":1682179200}';
El motor admite los siguientes tipos de campo para las tablas de MaxCompute: STRING, BOOLEAN, DOUBLE, BIGINT y DATETIME.
Sentencias de autorización
Al configurar una tabla de datos de MaxCompute, su cuenta de OpenSearch debe contar con los permisos DESCRIBE, SELECT y DOWNLOAD sobre la tabla, así como el permiso LABEL sobre sus campos.
-- Add the user account for the engine instance.
add user ****@aliyun.com;
-- Grant the required table permissions to the account.
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
-- If field-level permission verification is enabled in MaxCompute, data pull may fail for fields with high-level security labels, which prevents index creation. To resolve this, you must grant the account field-level access permissions.
-- Grant permissions on the entire project.
SET LABEL 3 to USER ****@aliyun.com
-- Grant permissions on a single table.
GRANT LABEL 3 ON TABLE table_xxx(col1, col2) TO ****@aliyun.com
Parámetros del origen de datos de MaxCompute
Vaya a Data Source Configuration y haga clic en Add Data Source. En la página de configuración, especifique los parámetros a continuación. De forma predeterminada, la opción automatic index rebuilding está establecida en Yes.
|
Parámetro |
Obligatorio |
Descripción |
|
Data source type |
Sí |
Seleccione MaxCompute. |
|
Data source name |
Sí |
Máximo 30 caracteres; solo se permiten letras, dígitos y guiones bajos (_). |
|
Project |
Sí |
Puede consultar el nombre del proyecto en la página de desarrollo de datos de MaxCompute. En DataStudio, el nombre del espacio de trabajo actual aparece en la lista desplegable Workspace de la barra de navegación superior. Nota
Para comprobar si su proyecto está en standard mode, vaya a la página Table Management en DataStudio y busque la tabla deseada. Un proyecto se encuentra en modo estándar si la etiqueta standard mode aparece junto al nombre de la tabla. En los proyectos en modo estándar, debe agregar |
|
AccessKey ID |
Sí |
Para obtener su AccessKey, pase el cursor sobre su avatar de perfil en la esquina superior derecha de la consola y haga clic en AccessKey Management. |
|
AccessKey Secret |
Sí |
|
|
Table |
Sí |
Nombre de la tabla de datos. |
|
Partition Key |
Sí |
Clave de partición de la tabla de datos. Por ejemplo: |