Running a query

Your application should act as an intermediary between your users and the platform to pass in a query and receive the queried data.

Gathering specific sets of data or scoping your data should occur within queries. Typically, the analytical work is done by the Macro Language query specified by the Query object. For more information on writing queries using the 1010data Insights Platform Macro Language, see the 1010data Reference Manual.

Use the Query method run to run queries.

In the example, the Query object is created in the Main function. The new Query object exampleQuery takes the path to the table that the query is being run against and the string containing the Macro Language query and the path to the table to which the query is applied. This Macro Language query selects the first 10 rows of the table. As a best practice, longer queries should be saved in a separate file and read.

import com.tentendata.javasdk1010v2.*;

public class DocumentationExample {
    
    public static void printRows(Row r) {
        System.out.println(r);
    }
    
    public static void main(String[] args) {
        String gateway = "https://www2.1010data.com/cgi-bin/gw.k";
        String user = "[USER_NAME]";
        String pwd = "[USER_PASSWORD]";
        String ops = "<sel value=\"(between(i_;1;10))\"/>";      
        Session testSession = new Session(gateway, user, pwd,
                                          LoginType.POSSESS);
        Query exampleQuery = new Query(testSession, path, ops);
        ResultSet results = exampleQuery.run();
    }
}
Note: [USER_NAME] and [USER_PASSWORD] are placeholders for valid Insights Platform user name and password.