-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support partition pseudo-columns in BigQuery
- Loading branch information
Showing
9 changed files
with
263 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryPseudoColumn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.bigquery; | ||
|
||
import com.google.cloud.bigquery.Field; | ||
import com.google.common.collect.ImmutableList; | ||
import io.trino.spi.connector.ColumnMetadata; | ||
import io.trino.spi.type.Type; | ||
|
||
import static io.trino.spi.type.DateType.DATE; | ||
import static io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_MICROS; | ||
|
||
public enum BigQueryPseudoColumn | ||
{ | ||
PARTITION_DATE("$partition_date", "_PARTITIONDATE", DATE, BigQueryType.DATE), | ||
PARTITION_TIME("$partition_time", "_PARTITIONTIME", TIMESTAMP_TZ_MICROS, BigQueryType.TIMESTAMP), | ||
/**/; | ||
|
||
private final String trinoColumnName; | ||
private final String bigqueryColumnName; | ||
private final Type trinoType; | ||
private final BigQueryType bigqueryType; | ||
|
||
BigQueryPseudoColumn(String trinoColumnName, String bigqueryColumnName, Type type, BigQueryType bigqueryType) | ||
{ | ||
this.trinoColumnName = trinoColumnName; | ||
this.bigqueryColumnName = bigqueryColumnName; | ||
this.trinoType = type; | ||
this.bigqueryType = bigqueryType; | ||
} | ||
|
||
public String getTrinoColumnName() | ||
{ | ||
return trinoColumnName; | ||
} | ||
|
||
public String getBigqueryColumnName() | ||
{ | ||
return bigqueryColumnName; | ||
} | ||
|
||
public BigQueryColumnHandle getColumnHandle() | ||
{ | ||
return new BigQueryColumnHandle( | ||
trinoColumnName, | ||
bigqueryType, | ||
Field.Mode.REQUIRED, | ||
null, | ||
null, | ||
ImmutableList.of(), | ||
null, | ||
true); | ||
} | ||
|
||
public ColumnMetadata getColumnMetadata() | ||
{ | ||
return ColumnMetadata.builder() | ||
.setName(trinoColumnName) | ||
.setType(trinoType) | ||
.setHidden(true) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.