Skip to content

Commit eabe06c

Browse files
committed
Updated BigQuery expression capabilities
1 parent e73c94f commit eabe06c

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/main/java/io/cdap/plugin/gcp/bigquery/relational/SQLExpressionFactory.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.cdap.plugin.gcp.bigquery.relational;
22

3+
import io.cdap.cdap.etl.api.engine.sql.StandardSQLCapabilities;
34
import io.cdap.cdap.etl.api.relational.Capability;
45
import io.cdap.cdap.etl.api.relational.CoreExpressionCapabilities;
56
import io.cdap.cdap.etl.api.relational.Expression;
@@ -12,7 +13,7 @@
1213
import io.cdap.cdap.etl.api.relational.StringExpressionFactoryType;
1314
import io.cdap.plugin.gcp.bigquery.sqlengine.builder.BigQueryBaseSQLBuilder;
1415

15-
import java.util.Arrays;
16+
import java.util.Collections;
1617
import java.util.HashSet;
1718
import java.util.Set;
1819

@@ -22,6 +23,15 @@
2223
*/
2324
public class SQLExpressionFactory implements ExpressionFactory<String> {
2425

26+
private static final Set<Capability> CAPABILITIES = Collections.unmodifiableSet(
27+
new HashSet<Capability>() {{
28+
add(StringExpressionFactoryType.SQL);
29+
add(StandardSQLCapabilities.BIGQUERY);
30+
add(CoreExpressionCapabilities.CAN_GET_QUALIFIED_DATASET_NAME);
31+
add(CoreExpressionCapabilities.CAN_GET_QUALIFIED_COLUMN_NAME);
32+
add(CoreExpressionCapabilities.CAN_SET_DATASET_ALIAS);
33+
}});
34+
2535
/**
2636
* Gets the expression factory type, which in this case is SQL.
2737
*
@@ -46,19 +56,17 @@ public Expression compile(String expression) {
4656
/**
4757
* Get the set of Capabilities supported, which in this case is SQL.
4858
*
49-
* @return A single capability, {@link StringExpressionFactoryType}.SQL.
59+
* @return a set containing all capabilities supported by this SQL engine.
5060
*/
5161
@Override
5262
public Set<Capability> getCapabilities() {
53-
return new HashSet<>(Arrays.asList(StringExpressionFactoryType.SQL,
54-
CoreExpressionCapabilities.CAN_GET_QUALIFIED_DATASET_NAME,
55-
CoreExpressionCapabilities.CAN_GET_QUALIFIED_COLUMN_NAME,
56-
CoreExpressionCapabilities.CAN_SET_DATASET_ALIAS));
63+
return CAPABILITIES;
5764
}
5865

5966
/**
6067
* Returns qualified dataset name for an expression. For BigQuery, dataset names are wrapped in quotes (`).
6168
* The resulting expression will be invalid if the relation is not a {@link BigQueryRelation}.
69+
*
6270
* @param relation supplied relation.
6371
* @return valid containing the column name wrapped in quotes; or invalid expression.
6472
*/
@@ -78,8 +86,9 @@ public ExtractableExpression<String> getQualifiedDataSetName(Relation relation)
7886
* Returns qualified dataset column for a column. For BigQuery, dataset names are wrapped in quotes (`).
7987
* The resulting expression will be invalid if the relation is not a {@link BigQueryRelation}
8088
* or the column does not exist in this relation.
89+
*
8190
* @param relation supplied relation.
82-
* @param column column name.
91+
* @param column column name.
8392
* @return valid containing the column name wrapped in quotes; or invalid expression.
8493
*/
8594
@Override
@@ -111,6 +120,7 @@ public Relation setDataSetAlias(Relation relation, String alias) { // Ensure
111120

112121
/**
113122
* Method used to build a qualified identified in BigQuery
123+
*
114124
* @param identifier identifier
115125
* @return Identifier wrapped in quotes (`)
116126
*/

0 commit comments

Comments
 (0)