I can create views using the Java API, but the query needs to be legacy sql:
public void createView(String dataSet, String viewName, String query) throws Exception {
Table content = new Table();
TableReference tableReference = new TableReference();
tableReference.setTableId(viewName);
tableReference.setDatasetId(dataSet);
tableReference.setProjectId(projectId);
content.setTableReference(tableReference);
ViewDefinition view = new ViewDefinition();
view.setQuery(query);
content.setView(view);
LOG.debug("View to create: " + content);
try {
if (tableExists(dataSet, viewName)) {
bigquery.tables().delete(projectId, dataSet, viewName).execute();
}
} catch (Exception e) {
LOG.error("Could not delete table", e);
}
bigquery.tables().insert(projectId, dataSet, content).setProjectId(projectId).execute();
}
Is there a way to create a BQ view with standard sql using the API?
#standardSQLat the start of the query itself?