private void setupJobData() { final JobLoader jobLoader = isInternal ? new InternalJobLoader(exception, completionLatch, job.getJobId(), jobResultsStore, store) : new ExternalJobLoader(completionLatch, exception); final JobData result = jobResultsStore.cacheNewJob(job.getJobId(), new JobDataImpl(jobLoader, job.getJobId())); job.setData(result); }
public JobDataFragmentImpl(final RecordBatches recordBatches, final int offsetInJobResults, final JobId jobId) { this.recordBatches = recordBatches; this.jobId = jobId; this.nameToColumnIndex = getColumnIndicesFromSchema(recordBatches.getSchema()); }
@Override public String getJobResultsTable() { loadIfNecessary(); return dataLoader.getJobResultsTable(); }
private static QueryProfile getQueryProfile(final String query) throws JobNotFoundException { final Job job = getJobsService().submitJob(JobRequest.newBuilder() .setSqlQuery(new SqlQuery(query, DEFAULT_USERNAME)) .setQueryType(QueryType.UI_INTERNAL_RUN) .setDatasetPath(DatasetPath.NONE.toNamespaceKey()) .setDatasetVersion(DatasetVersion.NONE) .build(), new NoOpJobStatusListener()); job.getData().loadIfNecessary(); return getJobsService().getProfile(job.getJobId(), 0); }
@Test public void testQueryOnFile() throws Exception { final JobsService jobService = l(JobsService.class); Job job = jobService.submitJob(JobRequest.newBuilder() .setSqlQuery(new SqlQuery("SELECT * FROM dachdfs_test.dir1.json.\"users.json\"", SampleDataPopulator.DEFAULT_USER_NAME)) .build(), NoOpJobStatusListener.INSTANCE); JobDataFragment jobData = job.getData().truncate(500); assertEquals(3, jobData.getReturnedRowCount()); assertEquals(2, jobData.getSchema().getFieldCount()); } }
protected void setSystemOption(String optionName, String optionValue) { final String query = String.format("ALTER SYSTEM SET \"%s\"=%s", optionName, optionValue); final Job job = getJobsService().submitJob(JobRequest.newBuilder() .setSqlQuery(new SqlQuery(query, DEFAULT_USERNAME)) .setQueryType(QueryType.UI_INTERNAL_RUN) .setDatasetPath(DatasetPath.NONE.toNamespaceKey()) .build(), NoOpJobStatusListener.INSTANCE); job.getData().loadIfNecessary(); }
@Test public void testAlterOption() throws Exception { SqlQuery ctas = getQueryFromSQL("alter session set \"planner.enable_multiphase_agg\"=true"); Job ctasJob = jobsService.submitJob(JobRequest.newBuilder() .setSqlQuery(ctas) .build(), NoOpJobStatusListener.INSTANCE); ctasJob.getData().loadIfNecessary(); }
@Test public void testReflectionsTable() { jobsService.submitJob(JobRequest.newBuilder() .setSqlQuery(getQueryFromSQL("SELECT * FROM sys.reflections")) .setDatasetPath(NONE_PATH) .build(), NoOpJobStatusListener.INSTANCE).getData().loadIfNecessary(); }
private JobData runExternalQuery(String sql) { return new JobUI(jobsService.submitJob(JobRequest.newBuilder() .setSqlQuery(new SqlQuery(sql, Arrays.asList("@" + DEFAULT_USER_NAME), DEFAULT_USER_NAME)) .build(), NoOpJobStatusListener.INSTANCE)).getData(); }
@Override public JobDataFragment truncate(int maxRows) { loadIfNecessary(); synchronized (dataObjectsToRelease) { checkNotClosed(); final JobDataFragmentImpl dataFragment = new JobDataFragmentImpl(dataLoader.load(0, maxRows), 0, jobId); dataObjectsToRelease.add(dataFragment); return dataFragment; } }
private QueryListener(Job job, UserResponseHandler connection) { this.job = job; externalId = JobsServiceUtil.getJobIdAsExternalId(job.getJobId()); this.responseHandler = Preconditions.checkNotNull(connection, "handler cannot be null"); this.statusListener = null; isInternal = false; setupJobData(); }
ExternalJobResultListener(AttemptId attemptId, UserResponseHandler connection, Job job, BufferAllocator allocator) { super(attemptId, job, allocator, NoOpJobStatusListener.INSTANCE); this.connection = connection; this.externalId = JobsServiceUtil.getJobIdAsExternalId(job.getJobId()); }
@Override public JobData load(JobId key) throws Exception { final JobDataImpl jobDataImpl = new JobDataImpl(new LateJobLoader(key), key); return newJobDataReference(jobDataImpl); } });
/** * Create a download job builder. * * @param downloadId download id used to find output of job (required) * @param fileName filename to use when data is downloaded (required) * @return new builder */ public static Builder newDownloadJobBuilder(String downloadId, String fileName) { return new Builder(downloadId, fileName); }
@Test public void testExplain() throws Exception { SqlQuery ctas = getQueryFromSQL("EXPLAIN PLAN FOR SELECT * FROM sys.version"); Job ctasJob = jobsService.submitJob(JobRequest.newBuilder() .setSqlQuery(ctas) .build(), NoOpJobStatusListener.INSTANCE); ctasJob.getData().loadIfNecessary(); }
@Test public void testMaterializationsTable() { jobsService.submitJob(JobRequest.newBuilder() .setSqlQuery(getQueryFromSQL("SELECT * FROM sys.materializations")) .setDatasetPath(NONE_PATH) .build(), NoOpJobStatusListener.INSTANCE).getData().loadIfNecessary(); } }
@Override public JobDataFragment range(int offset, int limit) { loadIfNecessary(); synchronized (dataObjectsToRelease) { checkNotClosed(); final JobDataFragmentImpl dataFragment = new JobDataFragmentImpl(dataLoader.load(offset, limit), offset, jobId); dataObjectsToRelease.add(dataFragment); return dataFragment; } }
private QueryListener(Job job, JobStatusListener statusListener) { this.job = job; externalId = JobsServiceUtil.getJobIdAsExternalId(job.getJobId()); this.responseHandler = null; this.statusListener = Preconditions.checkNotNull(statusListener, "statusListener cannot be null"); isInternal = true; setupJobData(); }
@Test public void testAliasedQuery() throws Exception { SqlQuery ctas = getQueryFromSQL("SHOW SCHEMAS"); Job ctasJob = jobsService.submitJob(JobRequest.newBuilder() .setSqlQuery(ctas) .build(), NoOpJobStatusListener.INSTANCE); ctasJob.getData().loadIfNecessary(); }