generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added different Visitors for BigQuerySink
- Loading branch information
1 parent
57ecb51
commit c90acfa
Showing
28 changed files
with
553 additions
and
875 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...finos/legend/engine/persistence/components/logicalplan/datasets/PartitionKeyAbstract.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,35 @@ | ||
// Copyright 2023 Goldman Sachs | ||
// | ||
// 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 org.finos.legend.engine.persistence.components.logicalplan.datasets; | ||
|
||
import org.finos.legend.engine.persistence.components.logicalplan.LogicalPlanNode; | ||
import org.finos.legend.engine.persistence.components.logicalplan.values.Value; | ||
import org.immutables.value.Value.Immutable; | ||
import org.immutables.value.Value.Parameter; | ||
import org.immutables.value.Value.Style; | ||
|
||
@Immutable | ||
@Style( | ||
typeAbstract = "*Abstract", | ||
typeImmutable = "*", | ||
jdkOnly = true, | ||
optionalAcceptNullable = true, | ||
strictBuilder = true | ||
) | ||
public interface PartitionKeyAbstract extends LogicalPlanNode | ||
{ | ||
@Parameter(order = 0) | ||
Value key(); | ||
} |
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
55 changes: 55 additions & 0 deletions
55
...s/legend/engine/persistence/components/relational/bigquery/sql/visitor/DeleteVisitor.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,55 @@ | ||
// Copyright 2022 Goldman Sachs | ||
// | ||
// 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 org.finos.legend.engine.persistence.components.relational.bigquery.sql.visitor; | ||
|
||
import org.finos.legend.engine.persistence.components.logicalplan.LogicalPlanNode; | ||
import org.finos.legend.engine.persistence.components.logicalplan.operations.Delete; | ||
import org.finos.legend.engine.persistence.components.logicalplan.operations.Truncate; | ||
import org.finos.legend.engine.persistence.components.physicalplan.PhysicalPlanNode; | ||
import org.finos.legend.engine.persistence.components.relational.sqldom.schemaops.statements.DeleteStatement; | ||
import org.finos.legend.engine.persistence.components.transformer.LogicalPlanVisitor; | ||
import org.finos.legend.engine.persistence.components.transformer.VisitorContext; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class DeleteVisitor implements LogicalPlanVisitor<Delete> | ||
{ | ||
|
||
/* | ||
DELETE always needs A WHERE CLAUSE IN BigQuery | ||
If the condition is not provided, default to Truncate | ||
*/ | ||
|
||
@Override | ||
public VisitorResult visit(PhysicalPlanNode prev, Delete current, VisitorContext context) | ||
{ | ||
if (!current.condition().isPresent()) | ||
{ | ||
return new TruncateVisitor().visit(prev, Truncate.of(current.dataset()), context); | ||
} | ||
|
||
DeleteStatement deleteStatement = new DeleteStatement(); | ||
prev.push(deleteStatement); | ||
|
||
List<LogicalPlanNode> logicalPlanNodeList = new ArrayList<>(); | ||
logicalPlanNodeList.add(current.dataset()); | ||
if (current.condition().isPresent()) | ||
{ | ||
logicalPlanNodeList.add(current.condition().get()); | ||
} | ||
return new VisitorResult(deleteStatement, logicalPlanNodeList); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...nd/engine/persistence/components/relational/bigquery/sql/visitor/PartitionKeyVisitor.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,40 @@ | ||
// Copyright 2023 Goldman Sachs | ||
// | ||
// 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 org.finos.legend.engine.persistence.components.relational.bigquery.sql.visitor; | ||
|
||
import org.finos.legend.engine.persistence.components.logicalplan.LogicalPlanNode; | ||
import org.finos.legend.engine.persistence.components.logicalplan.datasets.PartitionKey; | ||
import org.finos.legend.engine.persistence.components.physicalplan.PhysicalPlanNode; | ||
import org.finos.legend.engine.persistence.components.relational.sqldom.constraints.table.PartitionKeyConstraint; | ||
import org.finos.legend.engine.persistence.components.transformer.LogicalPlanVisitor; | ||
import org.finos.legend.engine.persistence.components.transformer.VisitorContext; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class PartitionKeyVisitor implements LogicalPlanVisitor<PartitionKey> | ||
{ | ||
@Override | ||
public VisitorResult visit(PhysicalPlanNode prev, PartitionKey current, VisitorContext context) | ||
{ | ||
PartitionKeyConstraint partitionKeyConstraint = new PartitionKeyConstraint(); | ||
prev.push(partitionKeyConstraint); | ||
|
||
List<LogicalPlanNode> logicalPlanNodes = new ArrayList<>(); | ||
logicalPlanNodes.add(current.key()); | ||
|
||
return new VisitorResult(partitionKeyConstraint, logicalPlanNodes); | ||
} | ||
} |
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.