Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created on 10-14-2016 07:25 AM - edited 09-16-2022 03:44 AM
We are doing spark programming in java language. The ‘DataFrame’ has been stored in temporary table and we are running multiple queries from this temporary table inside loop. The quires are running in sequential order. We need to run in parallel from temporary table. Please find code snippet below.
Thanks in advance for your cooperation.
HiveContext hiveContext = new HiveContext(sparkContext);
String mainQueryHql = getFileContent(mainQueryFilePath);
DataFrame df = hiveContext.sql(mainQueryHql).persist(StorageLevel.MEMORY_AND_DISK_SER());
df.show();
System.out.println("Total Records in Main Query " + df.count());
df.registerTempTable(tempTable);
ArrayList<DataFrame> dataFrameList = new ArrayList();
DataFrame dfSubQuery = null;
String subQuires = getFileContent(subQueryFilePath);
String[] alQuires = subQuires.split(";");
for(int i=0; i<alQuires.length; i++) {
System.out.println("Query no " + i +" is : " + alQuires[i]);
logger.debug("Query no " + i +" is : " + alQuires[i]);
dfSubQuery = hiveContext.sql(alQuires[i]);
dfSubQuery.show();
dataFrameList.add(dfSubQuery);
}