Skip to content

Commit

Permalink
Merge pull request #23 from GoogleCloudPlatform/version/v0.4.1
Browse files Browse the repository at this point in the history
Release v0.4.1
  • Loading branch information
Pablo Paglilla authored Oct 14, 2023
2 parents 9383d66 + 7fe211a commit 6df74bc
Show file tree
Hide file tree
Showing 44 changed files with 1,069 additions and 524 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ When analyzing queries using BigQuery semantics, you need to:
<dependency>
<groupId>com.google.zetasql.toolkit</groupId>
<artifactId>zetasql-toolkit-bigquery</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</dependency>
```

Expand Down Expand Up @@ -113,7 +113,7 @@ Similarly, when analyzing queries using Spanner semantics, you need to:
<dependency>
<groupId>com.google.zetasql.toolkit</groupId>
<artifactId>zetasql-toolkit-spanner</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</dependency>
```

Expand Down
29 changes: 24 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>com.google.zetasql.toolkit</groupId>
<artifactId>zetasql-toolkit</artifactId>
<version>0.4.1-SNAPSHOT</version>
<version>0.4.1</version>
<packaging>pom</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down Expand Up @@ -57,8 +57,8 @@
</developers>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.deploy.skip>false</maven.deploy.skip>
<maven.test.skip>true</maven.test.skip>
Expand All @@ -68,11 +68,11 @@
<slf4j.version>1.7.25</slf4j.version>
<!-- Testing dependency versions -->
<junit.version>5.9.3</junit.version>
<mockito.version>5.3.1</mockito.version>
<mockito.version>4.11.0</mockito.version>
<!-- Plugin versions -->
<maven.source.plugin.version>3.3.0</maven.source.plugin.version>
<maven.javadoc.plugin.version>3.5.0</maven.javadoc.plugin.version>
<maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
<maven.gpg.plugin.version>3.1.0</maven.gpg.plugin.version>
<maven.surefire.version>3.1.0</maven.surefire.version>
</properties>

Expand Down Expand Up @@ -137,7 +137,14 @@
</dependencies>
</dependencyManagement>


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
Expand Down Expand Up @@ -202,4 +209,16 @@
</snapshotRepository>
</distributionManagement>

<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>release</id>
</profile>
</profiles>

</project>
34 changes: 23 additions & 11 deletions zetasql-toolkit-bigquery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@
<parent>
<groupId>com.google.zetasql.toolkit</groupId>
<artifactId>zetasql-toolkit</artifactId>
<version>0.4.1-SNAPSHOT</version>
<version>0.4.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>zetasql-toolkit-bigquery</artifactId>
<version>0.4.1-SNAPSHOT</version>
<version>0.4.1</version>

<name>${project.groupId}:${project.artifactId}</name>

<properties>
<zetasql.toolkit.version>${project.version}</zetasql.toolkit.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>
Expand Down Expand Up @@ -113,13 +111,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.zetasql.toolkit</groupId>
<artifactId>zetasql-toolkit-core</artifactId>
<version>${zetasql.toolkit.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down Expand Up @@ -158,4 +149,25 @@
</plugins>
</build>

<profiles>
<profile>
<id>default</id>
<dependencies>
<dependency>
<groupId>com.google.zetasql.toolkit</groupId>
<artifactId>zetasql-toolkit-core</artifactId>
<version>${zetasql.toolkit.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>release</id>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ private TypeKind convertBigqueryTypeNameToTypeKind(StandardSQLTypeName bigqueryT
return TypeKind.TYPE_DATETIME;
case GEOGRAPHY:
return TypeKind.TYPE_GEOGRAPHY;
case JSON:
return TypeKind.TYPE_JSON;
default:
return TypeKind.TYPE_UNKNOWN;
}
Expand Down Expand Up @@ -201,7 +203,7 @@ 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
return List.of();
return ImmutableList.of();
}

ArrayList<SimpleColumn> columns =
Expand All @@ -216,7 +218,7 @@ private List<SimpleColumn> extractColumnsFromBigQueryTable(Table table) {

if (this.tableHasTimePartitioningPseudoColumns(table)) {
columns.addAll(
List.of(
ImmutableList.of(
new SimpleColumn(
tableId.getTable(),
"_PARTITIONTIME",
Expand Down Expand Up @@ -380,7 +382,7 @@ private FunctionArgumentType parseRoutineArgument(RoutineArgument argument) {
*/
private List<FunctionArgumentType> parseRoutineArguments(List<RoutineArgument> arguments) {
if (arguments == null) {
return List.of();
return ImmutableList.of();
}

return arguments.stream().map(this::parseRoutineArgument).collect(Collectors.toList());
Expand Down Expand Up @@ -430,7 +432,7 @@ private FunctionInfo buildFunction(Routine routine) {
.setNamePath(bigQueryReference.getNamePath())
.setGroup("UDF")
.setMode(Mode.SCALAR)
.setSignatures(List.of(signature))
.setSignatures(ImmutableList.of(signature))
.setLanguage(FunctionInfo.Language.valueOfOrUnspecified(routine.getLanguage()))
.setBody(Optional.ofNullable(routine.getBody()))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.CreateMode;
import com.google.zetasql.toolkit.catalog.CatalogOperations;
import com.google.zetasql.toolkit.catalog.ProcedureInfo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -44,30 +45,33 @@
*/
class BigQueryBuiltIns {

public static final Map<String, Type> TYPE_ALIASES =
Map.of(
"INT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64),
"SMALLINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64),
"INTEGER", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64),
"BIGINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64),
"TINYINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64),
"BYTEINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64),
"DECIMAL", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_NUMERIC),
"BIGDECIMAL", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_BIGNUMERIC));
public static final Map<String, Type> TYPE_ALIASES = new HashMap<>();

static {
TYPE_ALIASES.put("INT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
TYPE_ALIASES.put("SMALLINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
TYPE_ALIASES.put("INTEGER", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
TYPE_ALIASES.put("BIGINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
TYPE_ALIASES.put("TINYINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
TYPE_ALIASES.put("BYTEINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
TYPE_ALIASES.put("DECIMAL", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_NUMERIC));
TYPE_ALIASES.put(
"BIGDECIMAL", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_BIGNUMERIC));
}

private static final String BIGQUERY_FUNCTION_GROUP = "BigQuery";

public static final List<Function> FUNCTIONS =
List.of(
ImmutableList.of(
// CONTAINS_SUBSTR(STRING, ANY, [STRING]) -> BOOL
new Function(
"CONTAINS_SUBSTR",
BIGQUERY_FUNCTION_GROUP,
Mode.SCALAR,
List.of(
ImmutableList.of(
new FunctionSignature(
new FunctionArgumentType(TypeFactory.createSimpleType(TypeKind.TYPE_BOOL)),
List.of(
ImmutableList.of(
new FunctionArgumentType(
TypeFactory.createSimpleType(TypeKind.TYPE_STRING),
FunctionArgumentTypeOptions.builder()
Expand All @@ -94,10 +98,10 @@ class BigQueryBuiltIns {
"SEARCH",
BIGQUERY_FUNCTION_GROUP,
Mode.SCALAR,
List.of(
ImmutableList.of(
new FunctionSignature(
new FunctionArgumentType(TypeFactory.createSimpleType(TypeKind.TYPE_BOOL)),
List.of(
ImmutableList.of(
new FunctionArgumentType(
SignatureArgumentKind.ARG_TYPE_ANY_1,
FunctionArgumentTypeOptions.builder()
Expand Down Expand Up @@ -128,13 +132,13 @@ class BigQueryBuiltIns {
-1))));

public static final List<ProcedureInfo> PROCEDURES =
List.of(
ImmutableList.of(
// BQ.ABORT_SESSION([STRING])
new ProcedureInfo(
ImmutableList.of("BQ", "ABORT_SESSION"),
new FunctionSignature(
new FunctionArgumentType(TypeFactory.createSimpleType(TypeKind.TYPE_STRING)),
List.of(
ImmutableList.of(
new FunctionArgumentType(
TypeFactory.createSimpleType(TypeKind.TYPE_STRING),
FunctionArgumentTypeOptions.builder()
Expand All @@ -148,7 +152,7 @@ class BigQueryBuiltIns {
ImmutableList.of("BQ", "JOBS", "CANCEL"),
new FunctionSignature(
new FunctionArgumentType(TypeFactory.createSimpleType(TypeKind.TYPE_STRING)),
List.of(
ImmutableList.of(
new FunctionArgumentType(
TypeFactory.createSimpleType(TypeKind.TYPE_STRING),
FunctionArgumentTypeOptions.builder()
Expand All @@ -162,7 +166,7 @@ class BigQueryBuiltIns {
ImmutableList.of("BQ", "REFRESH_EXTERNAL_METADATA_CACHE"),
new FunctionSignature(
new FunctionArgumentType(TypeFactory.createSimpleType(TypeKind.TYPE_STRING)),
List.of(
ImmutableList.of(
new FunctionArgumentType(
TypeFactory.createSimpleType(TypeKind.TYPE_STRING),
FunctionArgumentTypeOptions.builder()
Expand All @@ -176,7 +180,7 @@ class BigQueryBuiltIns {
ImmutableList.of("BQ", "REFRESH_MATERIALIZED_VIEW"),
new FunctionSignature(
new FunctionArgumentType(TypeFactory.createSimpleType(TypeKind.TYPE_STRING)),
List.of(
ImmutableList.of(
new FunctionArgumentType(
TypeFactory.createSimpleType(TypeKind.TYPE_STRING),
FunctionArgumentTypeOptions.builder()
Expand All @@ -200,7 +204,7 @@ public static void addToCatalog(SimpleCatalog catalog) {
List<String> namePath = procedureInfo.getNamePath();
String procedureName = namePath.get(namePath.size() - 1);
List<List<String>> procedurePaths =
List.of(namePath, List.of(procedureName), List.of(String.join(".", namePath)));
ImmutableList.of(namePath, ImmutableList.of(procedureName), ImmutableList.of(String.join(".", namePath)));
CatalogOperations.createProcedureInCatalog(
catalog, procedurePaths, procedureInfo, CreateMode.CREATE_OR_REPLACE);
}
Expand Down
Loading

0 comments on commit 6df74bc

Please sign in to comment.