Alibaba MaxCompute

Create an Alibaba MaxCompute Datasource

  1. Navigate to: Resources > Data Sources

  2. Select the Alibaba MaxCompute Icon:

Data Source Inputs

Use Alibaba Max Compute

Read

Python
SQL
Python
%python
from odps.df import DataFrame
import pandas as pd
​
# Create a MaxCompute (ODPS) entrance object
o = z.getDatasource("zepl_docs_alibaba_maxcompute")
​
# Get table reference
table = o.get_table('sale_detail')
​
# Create ODPS DataFrame
odps_df = table.to_df()
​
# Convert to Pandas DataFrame
pandas_df = odps_df.to_pandas()
​
z.show(pandas_df)

Use z.getDatasource() to return MaxCompute entrance object: odps.core.ODPS​

SQL
%datasource.zepl_docs_alibaba_maxcompute
# Uncomment if full table scans are required for this query
# SET odps.sql.allow.fullscan=true;
​
SELECT * FROM sale_detail;

If you are experiencing this error ODPS-0130071 , please reference the Common SQL Errors documentation. This often means that you will need to enable full table scans by setting this run time parameter (odps.sql.allow.fullscan) to true

Write

Python
Python
%python
# Create a MaxCompute (ODPS) entrance object
o = z.getDatasource("zepl_docs_alibaba_maxcompute")
​
# Create data to write. Number of values per list must match the schema dtypes: o.get_table('sale_detail').schema
records = [["Samsung", 1234, 1000.00, "2020-01-01", "USA"], ["Apple", 9876, 5000.00, "2020-01-01", "USA"]]
​
# Write to table 'sale_detail', all records at a specific partition for sale_date and region
o.write_table('sale_detail', records, partition='sale_date="2020-01-01", region="USA', create_partition=True)

Configure Authentication

Generate User Access Key and Secret

  1. Login to your Alibaba Cloud console

  2. Navigate to Resource and Access Management (RAM)

  3. Select User > Then you specific user

  4. Select Create Access Key.

  5. Download this file and enter the corresponding values in the Zepl Data Source. If you lose this file, you will need to generate new Access Keys for this user.