in src/app/main/main.component.ts [461:521]
query() {
if (this.pending) {
return;
}
this.pending = true;
// We will save the query information to local store to be restored next
// time that the app is launched.
const dataFormValues = this.dataFormGroup.getRawValue();
this.projectID = dataFormValues.projectID;
const sql = dataFormValues.sql;
this.location = dataFormValues.location;
this.saveDataToLocalStorage(this.projectID, sql, this.location);
// Clear the existing sharing URL.
this.clearGeneratedSharingUrl();
let geoColumns;
this._dryRun()
.then((dryRunResponse) => {
geoColumns = dryRunResponse.schema.fields.filter((f) => f.type === 'GEOGRAPHY');
// Wrap the user's SQL query, replacing geography columns with GeoJSON.
this.jobWrappedSql = this.convertToGeovizQuery(sql, geoColumns, dryRunResponse.schema.fields.length);
return this.dataService.query(this.projectID, this.jobWrappedSql, this.location);
})
.then(({columns, columnNames, rows, stats, totalRows, pageToken, jobID, totalBytesProcessed}) => {
this.columns = columns;
this.columnNames = columnNames;
this.geoColumnNames = geoColumns.map((f) => f.name);
this.rows = rows;
this.stats = stats;
this.data = new MatTableDataSource(rows.slice(0, MAX_RESULTS_PREVIEW));
this.schemaFormGroup.patchValue({geoColumn: geoColumns[0].name});
this.totalRows = totalRows;
this.jobID = jobID;
this.bytesProcessed = totalBytesProcessed;
return this.analyticsService.reportBenchmark(
'load_complete',
'map',
this.getResults(0, this.projectID, pageToken, this.location, jobID)
);
})
.catch((e) => {
const error = e && e.result && e.result.error || {};
if (error.status === 'INVALID_ARGUMENT' && error.message.match(/^Unrecognized name: f\d+_/)) {
this.showMessage(
'Geography columns must provide a name. For example, "SELECT ST_GEOGPOINT(1,2)" could ' +
'be changed to "SELECT ST_GEOGPOINT(1,2) geo".'
);
} else {
this.showMessage(parseErrorMessage(e));
}
})
.then(() => {
this.pending = false;
this._changeDetectorRef.detectChanges();
});
}