Skip to content

Commit

Permalink
Remove requirement to specify partitionBy when using clusterBy for Bi…
Browse files Browse the repository at this point in the history
…gQuery (#961)
  • Loading branch information
lewish authored Aug 21, 2020
1 parent 3db05a5 commit 4b7a7d2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 26 deletions.
14 changes: 3 additions & 11 deletions core/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,20 +650,12 @@ export class Session {

// BigQuery config
if (!!table.bigquery) {
if (table.bigquery.partitionBy && table.type === "view") {
this.compileError(
`partitionBy/clusterBy are not valid for BigQuery views; they are only valid for tables`,
table.fileName,
table.name
);
}
if (
!!table.bigquery.clusterBy &&
table.bigquery.clusterBy.length > 0 &&
!table.bigquery.partitionBy
(table.bigquery.partitionBy || table.bigquery.clusterBy?.length) &&
table.type === "view"
) {
this.compileError(
`clusterBy is not valid without partitionBy`,
`partitionBy/clusterBy are not valid for BigQuery views; they are only valid for tables`,
table.fileName,
table.name
);
Expand Down
31 changes: 17 additions & 14 deletions tests/core/core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,27 +461,30 @@ suite("@dataform/core", () => {
partitionBy: "some_partition"
}
});
session.publish("example_clusterBy_but_no_partitionBy_fail", {
type: "table",
session.publish("example_clusterBy_view_fail", {
type: "view",
bigquery: {
clusterBy: ["some_column", "some_other_column"]
clusterBy: ["some_cluster"]
}
});

const graph = session.compile();
expect(
graph.graphErrors.compilationErrors
.filter(item => item.actionName === "schema.example_partitionBy_view_fail")
.map(item => item.message)
).to.deep.equals([
`partitionBy/clusterBy are not valid for BigQuery views; they are only valid for tables`
]);

expect(
graph.graphErrors.compilationErrors
.filter(item => item.actionName === "schema.example_clusterBy_but_no_partitionBy_fail")
.map(item => item.message)
).to.deep.equals([`clusterBy is not valid without partitionBy`]);
graph.graphErrors.compilationErrors.map(({ message, actionName }) => ({
message,
actionName
}))
).has.deep.members([
{
actionName: "schema.example_partitionBy_view_fail",
message: `partitionBy/clusterBy are not valid for BigQuery views; they are only valid for tables`
},
{
actionName: "schema.example_clusterBy_view_fail",
message: `partitionBy/clusterBy are not valid for BigQuery views; they are only valid for tables`
}
]);
});

test("validation_bigquery_pass", () => {
Expand Down
2 changes: 1 addition & 1 deletion version.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# NOTE: If you change the format of this line, you must change the bash command
# in /scripts/publish to extract the version string correctly.
DF_VERSION = "1.9.1"
DF_VERSION = "1.9.2"

0 comments on commit 4b7a7d2

Please sign in to comment.