Skip to content

Commit

Permalink
Configure google-java-format through the Spotless plugin (#39)
Browse files Browse the repository at this point in the history
* Configure google-java-format with spotless plugin
* Apply google-java-format codebase-wide
* Reformat poms
  • Loading branch information
Pablo Paglilla authored May 7, 2024
1 parent c8c24d9 commit f32be55
Show file tree
Hide file tree
Showing 55 changed files with 2,298 additions and 2,137 deletions.
414 changes: 223 additions & 191 deletions pom.xml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions zetasql-toolkit-bigquery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ private List<SimpleColumn> extractColumnsFromBigQueryTable(Table table) {

if (table.getDefinition().getSchema() == null) {
// BigQuery tables can have no columns, in which case the schema is null
// One such table is bigquery-public-data.america_health_rankings.america_health_rankings
// One such table is
// bigquery-public-data.america_health_rankings.america_health_rankings
return ImmutableList.of();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,10 @@ class BigQueryBuiltIns {
public static void addToCatalog(SimpleCatalog catalog) {
TYPE_ALIASES.forEach(catalog::addType);
FUNCTIONS.forEach(catalog::addFunction);
PROCEDURES.forEach(procedure ->
CatalogOperations.createProcedureInCatalog(
catalog, procedure.getFullName(), procedure, CreateMode.CREATE_DEFAULT));
PROCEDURES.forEach(
procedure ->
CatalogOperations.createProcedureInCatalog(
catalog, procedure.getFullName(), procedure, CreateMode.CREATE_DEFAULT));
}

private BigQueryBuiltIns() {}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,4 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(projectId.toLowerCase(), datasetId, resourceName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ private Table fetchTableFromAPI(BigQueryReference reference) {
* Fetches a BigQuery Table from the API. Results are cached indefinitely.
*
* @param projectId The default BigQuery project id
* @param tableReference The String referencing the table,
* e.g. "project.dataset.table"
* @param tableReference The String referencing the table, e.g. "project.dataset.table"
* @return A Result&lt;Table&gt; containing the fetched Table
*/
public Result<Table> fetchTable(String projectId, String tableReference) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,153 +48,152 @@ private Set<BigQueryReference> parseBigQueryReferences(
public List<SimpleTable> getTables(String projectId, List<String> tableReferences) {
Set<BigQueryReference> references = parseBigQueryReferences(projectId, tableReferences);

return catalogResources.getTables()
.stream()
.filter(table -> {
BigQueryReference tableReference = BigQueryReference.from(projectId, table.getName());
return references.contains(tableReference);
})
return catalogResources.getTables().stream()
.filter(
table -> {
BigQueryReference tableReference = BigQueryReference.from(projectId, table.getName());
return references.contains(tableReference);
})
.collect(Collectors.toList());
}

@Override
public List<SimpleTable> getAllTablesInDataset(String projectId, String datasetName) {
return catalogResources.getTables()
.stream()
.filter(table -> {
BigQueryReference tableReference = BigQueryReference.from(projectId, table.getName());
return tableReference.getProjectId().equalsIgnoreCase(projectId)
&& tableReference.getDatasetId().equals(datasetName);
})
return catalogResources.getTables().stream()
.filter(
table -> {
BigQueryReference tableReference = BigQueryReference.from(projectId, table.getName());
return tableReference.getProjectId().equalsIgnoreCase(projectId)
&& tableReference.getDatasetId().equals(datasetName);
})
.collect(Collectors.toList());
}

@Override
public List<SimpleTable> getAllTablesInProject(String projectId) {
return catalogResources.getTables()
.stream()
.filter(table -> {
BigQueryReference tableReference = BigQueryReference.from(projectId, table.getName());
return tableReference.getProjectId().equalsIgnoreCase(projectId);
})
return catalogResources.getTables().stream()
.filter(
table -> {
BigQueryReference tableReference = BigQueryReference.from(projectId, table.getName());
return tableReference.getProjectId().equalsIgnoreCase(projectId);
})
.collect(Collectors.toList());
}

@Override
public List<FunctionInfo> getFunctions(String projectId, List<String> functionReferences) {
Set<BigQueryReference> references = parseBigQueryReferences(projectId, functionReferences);

return catalogResources.getFunctions()
.stream()
.filter(function -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, function.getFullName());
return references.contains(functionReference);
})
return catalogResources.getFunctions().stream()
.filter(
function -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, function.getFullName());
return references.contains(functionReference);
})
.collect(Collectors.toList());
}

@Override
public List<FunctionInfo> getAllFunctionsInDataset(String projectId, String datasetName) {
return catalogResources.getFunctions()
.stream()
.filter(function -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, function.getFullName());
return functionReference.getProjectId().equalsIgnoreCase(projectId)
&& functionReference.getDatasetId().equals(datasetName);
})
return catalogResources.getFunctions().stream()
.filter(
function -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, function.getFullName());
return functionReference.getProjectId().equalsIgnoreCase(projectId)
&& functionReference.getDatasetId().equals(datasetName);
})
.collect(Collectors.toList());
}

@Override
public List<FunctionInfo> getAllFunctionsInProject(String projectId) {
return catalogResources.getFunctions()
.stream()
.filter(function -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, function.getFullName());
return functionReference.getProjectId().equalsIgnoreCase(projectId);
})
return catalogResources.getFunctions().stream()
.filter(
function -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, function.getFullName());
return functionReference.getProjectId().equalsIgnoreCase(projectId);
})
.collect(Collectors.toList());
}

@Override
public List<TVFInfo> getTVFs(String projectId, List<String> functionReferences) {
Set<BigQueryReference> references = parseBigQueryReferences(projectId, functionReferences);

return catalogResources.getTVFs()
.stream()
.filter(tvf -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, tvf.getFullName());
return references.contains(functionReference);
})
return catalogResources.getTVFs().stream()
.filter(
tvf -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, tvf.getFullName());
return references.contains(functionReference);
})
.collect(Collectors.toList());
}

@Override
public List<TVFInfo> getAllTVFsInDataset(String projectId, String datasetName) {
return catalogResources.getTVFs()
.stream()
.filter(tvf -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, tvf.getFullName());
return functionReference.getProjectId().equalsIgnoreCase(projectId)
&& functionReference.getDatasetId().equals(datasetName);
})
return catalogResources.getTVFs().stream()
.filter(
tvf -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, tvf.getFullName());
return functionReference.getProjectId().equalsIgnoreCase(projectId)
&& functionReference.getDatasetId().equals(datasetName);
})
.collect(Collectors.toList());
}

@Override
public List<TVFInfo> getAllTVFsInProject(String projectId) {
return catalogResources.getTVFs()
.stream()
.filter(tvf -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, tvf.getFullName());
return functionReference.getProjectId().equalsIgnoreCase(projectId);
})
return catalogResources.getTVFs().stream()
.filter(
tvf -> {
BigQueryReference functionReference =
BigQueryReference.from(projectId, tvf.getFullName());
return functionReference.getProjectId().equalsIgnoreCase(projectId);
})
.collect(Collectors.toList());
}

@Override
public List<ProcedureInfo> getProcedures(String projectId, List<String> procedureReferences) {
Set<BigQueryReference> references = parseBigQueryReferences(projectId, procedureReferences);

return catalogResources.getProcedures()
.stream()
.filter(procedure -> {
BigQueryReference procedureReference =
BigQueryReference.from(projectId, procedure.getFullName());
return references.contains(procedureReference);
})
return catalogResources.getProcedures().stream()
.filter(
procedure -> {
BigQueryReference procedureReference =
BigQueryReference.from(projectId, procedure.getFullName());
return references.contains(procedureReference);
})
.collect(Collectors.toList());
}

@Override
public List<ProcedureInfo> getAllProceduresInDataset(String projectId, String datasetName) {
return catalogResources.getProcedures()
.stream()
.filter(procedure -> {
BigQueryReference procedureReference =
BigQueryReference.from(projectId, procedure.getFullName());
return procedureReference.getProjectId().equalsIgnoreCase(projectId)
&& procedureReference.getDatasetId().equals(datasetName);
})
return catalogResources.getProcedures().stream()
.filter(
procedure -> {
BigQueryReference procedureReference =
BigQueryReference.from(projectId, procedure.getFullName());
return procedureReference.getProjectId().equalsIgnoreCase(projectId)
&& procedureReference.getDatasetId().equals(datasetName);
})
.collect(Collectors.toList());
}

@Override
public List<ProcedureInfo> getAllProceduresInProject(String projectId) {
return catalogResources.getProcedures()
.stream()
.filter(procedure -> {
BigQueryReference procedureReference =
BigQueryReference.from(projectId, procedure.getFullName());
return procedureReference.getProjectId().equalsIgnoreCase(projectId);
})
return catalogResources.getProcedures().stream()
.filter(
procedure -> {
BigQueryReference procedureReference =
BigQueryReference.from(projectId, procedure.getFullName());
return procedureReference.getProjectId().equalsIgnoreCase(projectId);
})
.collect(Collectors.toList());
}

}
Loading

0 comments on commit f32be55

Please sign in to comment.