generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persistence Component: Implement type conversion logic in Snowflake f…
…or digest generation (#2849)
- Loading branch information
Showing
14 changed files
with
225 additions
and
35 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
38 changes: 38 additions & 0 deletions
38
...g/finos/legend/engine/persistence/components/logicalplan/values/CastFunctionAbstract.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,38 @@ | ||
// Copyright 2024 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.values; | ||
|
||
import org.finos.legend.engine.persistence.components.logicalplan.datasets.FieldType; | ||
|
||
import static org.immutables.value.Value.Immutable; | ||
import static org.immutables.value.Value.Parameter; | ||
import static org.immutables.value.Value.Style; | ||
|
||
@Immutable | ||
@Style( | ||
typeAbstract = "*Abstract", | ||
typeImmutable = "*", | ||
jdkOnly = true, | ||
optionalAcceptNullable = true, | ||
strictBuilder = true | ||
) | ||
public interface CastFunctionAbstract extends Value | ||
{ | ||
@Parameter(order = 0) | ||
Value field(); | ||
|
||
@Parameter(order = 1) | ||
FieldType type(); | ||
} |
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
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
49 changes: 49 additions & 0 deletions
49
...d/engine/persistence/components/relational/snowflake/sql/visitor/CastFunctionVisitor.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,49 @@ | ||
// Copyright 2024 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.snowflake.sql.visitor; | ||
|
||
import org.finos.legend.engine.persistence.components.logicalplan.LogicalPlanNode; | ||
import org.finos.legend.engine.persistence.components.logicalplan.values.CastFunction; | ||
import org.finos.legend.engine.persistence.components.optimizer.Optimizer; | ||
import org.finos.legend.engine.persistence.components.physicalplan.PhysicalPlanNode; | ||
import org.finos.legend.engine.persistence.components.relational.snowflake.sql.SnowflakeDataTypeMapping; | ||
import org.finos.legend.engine.persistence.components.relational.sqldom.schema.DataType; | ||
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 CastFunctionVisitor implements LogicalPlanVisitor<CastFunction> | ||
{ | ||
@Override | ||
public VisitorResult visit(PhysicalPlanNode prev, CastFunction current, VisitorContext context) | ||
{ | ||
DataType dataType = new SnowflakeDataTypeMapping().getDataType(current.type()); | ||
|
||
org.finos.legend.engine.persistence.components.relational.snowflake.sqldom.schemaops.values.CastFunction castFunction = | ||
new org.finos.legend.engine.persistence.components.relational.snowflake.sqldom.schemaops.values.CastFunction(dataType, context.quoteIdentifier()); | ||
for (Optimizer optimizer : context.optimizers()) | ||
{ | ||
castFunction = (org.finos.legend.engine.persistence.components.relational.snowflake.sqldom.schemaops.values.CastFunction) optimizer.optimize(castFunction); | ||
} | ||
prev.push(castFunction); | ||
|
||
List<LogicalPlanNode> logicalPlanNodeList = new ArrayList<>(); | ||
logicalPlanNodeList.add(current.field()); | ||
|
||
return new VisitorResult(castFunction, logicalPlanNodeList); | ||
} | ||
} |
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.