Obtaining SQL Query Result in Pages Using MaxCompute

select * from (select row_number() over() as row_id,* from orders_delta)t where row_id between 10 and 20;
Odps odps = OdpsUtils.newDefaultOdps(); // Initialize the MaxCompute object
Instance i = SQLTask.run(odps, "select * from wc_in;");

// Create InstanceTunnel
InstanceTunnel tunnel = new InstanceTunnel(odps);
// Create DownloadSession based on the instance ID
InstanceTunnel.DownloadSession session = tunnel.createDownloadSession(odps.getDefaultProject(), i.getId());

long count = session.getRecordCount();
// The count of outputs results

// The code for obtaining the data is the same as in Table Tunnel.
TunnelRecordReader reader = session. openRecordReader (0, Count );
Record record;
While(Record = reader.Read())! = null) {
For(IntCol =0; Col <session.GetSchema().GetColumns().Size(); ++ Col ){
// The fields in the wc_in table are all strings, and the output is printed directly here.
System. out.Println(Record.Get(Col ));
TunnelRecordReader reader = downloadSession. openRecordReader (100,20);



Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store