From 119652c0a14b5ce4386c8a1479a473307d0e243e Mon Sep 17 00:00:00 2001 From: prasar-ashutosh Date: Wed, 7 Aug 2024 02:49:53 +0530 Subject: [PATCH] Persistence: Categorise errors among data, internal and transient errors (#2925) --- .../exception/EmptyBatchException.java | 30 +++++++ .../exception/JsonReadOrWriteException.java | 29 +++++++ .../exception/PersistenceException.java | 31 ++++++++ .../StagedFilesDatasetProperties.java | 4 +- .../planner/UnitemporalSnapshotPlanner.java | 3 +- .../components/util/LogicalPlanUtils.java | 3 +- .../components/importer/JsonDataImporter.java | 3 +- .../IncompatibleSchemaChangeException.java | 10 ++- .../bigquery/executor/BigQueryExecutor.java | 2 +- .../bigquery/executor/BigQueryHelper.java | 4 +- .../components/relational/api/ApiUtils.java | 3 +- .../api/RelationalIngestorAbstract.java | 9 ++- .../exception/ConnectionException.java | 34 ++++++++ .../ConstraintViolationException.java | 34 ++++++++ .../exception/DataQualityException.java | 9 ++- .../exception/DataRelatedException.java | 34 ++++++++ .../exception/DynamicSqlErrorException.java | 34 ++++++++ .../exception/SqlExecutionException.java | 46 +++++++++++ .../SqlExecutionExceptionMapper.java | 53 +++++++++++++ ...axErrorOrAccessRuleViolationException.java | 34 ++++++++ .../TransactionRollbackException.java | 34 ++++++++ .../relational/jdbc/JdbcHelper.java | 78 ++++++++++++------- .../jdbc/JdbcTransactionManager.java | 42 ++++------ .../relational/sqldom/SqlDomException.java | 10 ++- ...2StagedFilesDatasetPropertiesAbstract.java | 6 +- .../relational/snowflake/SnowflakeSink.java | 3 +- 26 files changed, 508 insertions(+), 74 deletions(-) create mode 100644 legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/EmptyBatchException.java create mode 100644 legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/JsonReadOrWriteException.java create mode 100644 legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/PersistenceException.java create mode 100644 legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/ConnectionException.java create mode 100644 legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/ConstraintViolationException.java create mode 100644 legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DataRelatedException.java create mode 100644 legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DynamicSqlErrorException.java create mode 100644 legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlExecutionException.java create mode 100644 legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlExecutionExceptionMapper.java create mode 100644 legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlSyntaxErrorOrAccessRuleViolationException.java create mode 100644 legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/TransactionRollbackException.java diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/EmptyBatchException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/EmptyBatchException.java new file mode 100644 index 00000000000..abb99e8434c --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/EmptyBatchException.java @@ -0,0 +1,30 @@ +// 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.exception; + +public class EmptyBatchException extends PersistenceException +{ + + @Override + public boolean isRecoverable() + { + return false; + } + + public EmptyBatchException(String message) + { + super(message); + } +} diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/JsonReadOrWriteException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/JsonReadOrWriteException.java new file mode 100644 index 00000000000..1ef8c0030a7 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/JsonReadOrWriteException.java @@ -0,0 +1,29 @@ +// 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.exception; + +public class JsonReadOrWriteException extends PersistenceException +{ + public JsonReadOrWriteException(String message, Throwable cause) + { + super(message, cause); + } + + @Override + public boolean isRecoverable() + { + return false; + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/PersistenceException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/PersistenceException.java new file mode 100644 index 00000000000..7a93ef83b00 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/exception/PersistenceException.java @@ -0,0 +1,31 @@ +// 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.exception; + +public abstract class PersistenceException extends RuntimeException +{ + + public abstract boolean isRecoverable(); + + public PersistenceException(String message, Throwable cause) + { + super(message, cause); + } + + public PersistenceException(String message) + { + super(message); + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/datasets/StagedFilesDatasetProperties.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/datasets/StagedFilesDatasetProperties.java index b6270d52b60..d792ff78adc 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/datasets/StagedFilesDatasetProperties.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/datasets/StagedFilesDatasetProperties.java @@ -35,11 +35,11 @@ default void validate() { if (filePatterns().size() > 0 && filePaths().size() > 0) { - throw new IllegalArgumentException("Cannot build StagedFilesDatasetProperties, Only one out of filePatterns and filePaths should be provided"); + throw new IllegalStateException("Cannot build StagedFilesDatasetProperties, Only one out of filePatterns and filePaths should be provided"); } if (filePatterns().size() == 0 && filePaths().size() == 0) { - throw new IllegalArgumentException("Cannot build StagedFilesDatasetProperties, Either one of filePatterns and filePaths must be provided"); + throw new IllegalStateException("Cannot build StagedFilesDatasetProperties, Either one of filePatterns and filePaths must be provided"); } } } \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/planner/UnitemporalSnapshotPlanner.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/planner/UnitemporalSnapshotPlanner.java index 6b5e9158e2b..d85e53a7aa4 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/planner/UnitemporalSnapshotPlanner.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/planner/UnitemporalSnapshotPlanner.java @@ -16,6 +16,7 @@ import org.finos.legend.engine.persistence.components.common.Datasets; import org.finos.legend.engine.persistence.components.common.Resources; +import org.finos.legend.engine.persistence.components.exception.EmptyBatchException; import org.finos.legend.engine.persistence.components.ingestmode.UnitemporalSnapshot; import org.finos.legend.engine.persistence.components.ingestmode.emptyhandling.DeleteTargetDataAbstract; import org.finos.legend.engine.persistence.components.ingestmode.emptyhandling.EmptyDatasetHandlingVisitor; @@ -277,7 +278,7 @@ public LogicalPlan visitDeleteTargetData(DeleteTargetDataAbstract deleteTargetDa @Override public LogicalPlan visitFailEmptyBatch(FailEmptyBatchAbstract failEmptyBatchAbstract) { - throw new RuntimeException("Encountered an Empty Batch, FailEmptyBatch is enabled, so failing the batch!"); + throw new EmptyBatchException("Encountered an Empty Batch, FailEmptyBatch is enabled, so failing the batch!"); } } } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/util/LogicalPlanUtils.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/util/LogicalPlanUtils.java index b7aabe6d646..2386a432a26 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/util/LogicalPlanUtils.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/util/LogicalPlanUtils.java @@ -19,6 +19,7 @@ import org.finos.legend.engine.persistence.components.common.DatasetFilter; import org.finos.legend.engine.persistence.components.common.Datasets; import org.finos.legend.engine.persistence.components.common.OptimizationFilter; +import org.finos.legend.engine.persistence.components.exception.JsonReadOrWriteException; import org.finos.legend.engine.persistence.components.ingestmode.IngestMode; import org.finos.legend.engine.persistence.components.ingestmode.deduplication.*; import org.finos.legend.engine.persistence.components.ingestmode.versioning.*; @@ -322,7 +323,7 @@ public static Optional getStringValueFromMap(Map ma } catch (JsonProcessingException e) { - throw new RuntimeException(e); + throw new JsonReadOrWriteException(e.getMessage(), e); } } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/importer/JsonDataImporter.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/importer/JsonDataImporter.java index ba2e88b55aa..f5f53dd9750 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/importer/JsonDataImporter.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/importer/JsonDataImporter.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.finos.legend.engine.persistence.components.exception.JsonReadOrWriteException; import org.finos.legend.engine.persistence.components.executor.DigestInfo; import org.finos.legend.engine.persistence.components.executor.Executor; import org.finos.legend.engine.persistence.components.executor.ResultData; @@ -73,7 +74,7 @@ public void importData(ExternalDatasetReference externalDatasetReference, Digest } catch (JsonProcessingException e) { - throw new RuntimeException(e); + throw new JsonReadOrWriteException(e.getMessage(), e); } for (Map row : rows) diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/schemaevolution/IncompatibleSchemaChangeException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/schemaevolution/IncompatibleSchemaChangeException.java index 4ff878bf750..110b3db2dd7 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/schemaevolution/IncompatibleSchemaChangeException.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/schemaevolution/IncompatibleSchemaChangeException.java @@ -14,8 +14,16 @@ package org.finos.legend.engine.persistence.components.schemaevolution; -public class IncompatibleSchemaChangeException extends RuntimeException +import org.finos.legend.engine.persistence.components.exception.PersistenceException; + +public class IncompatibleSchemaChangeException extends PersistenceException { + @Override + public boolean isRecoverable() + { + return false; + } + public IncompatibleSchemaChangeException(String message) { super(message); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryExecutor.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryExecutor.java index bd89b59e866..e11e871cb9d 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryExecutor.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryExecutor.java @@ -96,7 +96,7 @@ public List executePhysicalPlanAndGetResults(SqlPlan physicalPlan) @Override public List executePhysicalPlanAndGetResults(SqlPlan physicalPlan, int rows) { - throw new RuntimeException("Not implemented for Big Query"); + throw new UnsupportedOperationException("Not implemented for Big Query"); } @Override diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryHelper.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryHelper.java index 60d23a941df..863fd1d2089 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryHelper.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryHelper.java @@ -73,7 +73,7 @@ public static BigQueryHelper of(BigQuery bigQuery) { return new BigQueryHelper(bigQuery); } - throw new RuntimeException("Sink initialized without connection can only be used for SQL generation APIs, but used with ingestion API"); + throw new IllegalStateException("Sink initialized without connection can only be used for SQL generation APIs, but used with ingestion API"); } private BigQueryHelper(BigQuery bigQuery) @@ -371,7 +371,7 @@ public void executeStatements(List sqls) @Override public List> executeQuery(String sql, int rows) { - throw new RuntimeException("Not implemented for Big Query"); + throw new UnsupportedOperationException("Not implemented for Big Query"); } public void executeStatementsInANewTransaction(List sqls) diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/ApiUtils.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/ApiUtils.java index cf7f439a738..35b595c798b 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/ApiUtils.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/ApiUtils.java @@ -38,6 +38,7 @@ import org.finos.legend.engine.persistence.components.planner.Planner; import org.finos.legend.engine.persistence.components.relational.CaseConversion; import org.finos.legend.engine.persistence.components.relational.SqlPlan; +import org.finos.legend.engine.persistence.components.exception.JsonReadOrWriteException; import org.finos.legend.engine.persistence.components.relational.sql.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.transformer.Transformer; @@ -361,7 +362,7 @@ public static String buildErrorRecord(List allColumns, Map performDryRun() } else { - throw new RuntimeException("Dry Run not supported for this ingest Mode : " + enrichedIngestMode.getClass().getSimpleName()); + throw new UnsupportedOperationException("Dry Run not supported for this ingest Mode : " + enrichedIngestMode.getClass().getSimpleName()); } } @@ -927,7 +928,7 @@ private String writeValueAsString(Map statisticByName) } catch (JsonProcessingException e) { - throw new RuntimeException(e); + throw new JsonReadOrWriteException(e.getMessage(), e); } } @@ -939,7 +940,7 @@ private Map readValueAsMap(String batchStatistics) } catch (JsonProcessingException e) { - throw new RuntimeException(e); + throw new JsonReadOrWriteException(e.getMessage(), e); } } @@ -1019,7 +1020,7 @@ private Map extractPlaceHolderKeyValues(Datasets datas } catch (JsonProcessingException e) { - throw new IllegalStateException("Unable to parse additional metadata"); + throw new JsonReadOrWriteException("Unable to parse additional metadata", e); } // Handle batch timestamp diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/ConnectionException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/ConnectionException.java new file mode 100644 index 00000000000..e3e60aa65cc --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/ConnectionException.java @@ -0,0 +1,34 @@ +// 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.exception; + +public class ConnectionException extends SqlExecutionException +{ + + /* + SQL STATE: 08*** + */ + + public ConnectionException(String message, Throwable cause, String SQLState, int vendorCode) + { + super(message, cause, SQLState, vendorCode); + } + + @Override + public boolean isRecoverable() + { + return true; + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/ConstraintViolationException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/ConstraintViolationException.java new file mode 100644 index 00000000000..eb9eee0e6a1 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/ConstraintViolationException.java @@ -0,0 +1,34 @@ +// 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.exception; + +public class ConstraintViolationException extends SqlExecutionException +{ + + /* + SQL STATE: 23*** + */ + + public ConstraintViolationException(String message, Throwable cause, String SQLState, int vendorCode) + { + super(message, cause, SQLState, vendorCode); + } + + @Override + public boolean isRecoverable() + { + return false; + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DataQualityException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DataQualityException.java index eb8c44cf446..0595386131d 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DataQualityException.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DataQualityException.java @@ -14,11 +14,12 @@ package org.finos.legend.engine.persistence.components.relational.exception; +import org.finos.legend.engine.persistence.components.exception.PersistenceException; import org.finos.legend.engine.persistence.components.relational.api.DataError; import java.util.List; -public class DataQualityException extends RuntimeException +public class DataQualityException extends PersistenceException { private List dataErrors; @@ -32,4 +33,10 @@ public DataQualityException(String message, List dataErrors) super(message); this.dataErrors = dataErrors; } + + @Override + public boolean isRecoverable() + { + return false; + } } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DataRelatedException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DataRelatedException.java new file mode 100644 index 00000000000..b4d71592cb6 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DataRelatedException.java @@ -0,0 +1,34 @@ +// 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.exception; + +public class DataRelatedException extends SqlExecutionException +{ + + /* + SQL STATE: 20***, 21***, 22*** + */ + + public DataRelatedException(String message, Throwable cause, String SQLState, int vendorCode) + { + super(message, cause, SQLState, vendorCode); + } + + @Override + public boolean isRecoverable() + { + return false; + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DynamicSqlErrorException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DynamicSqlErrorException.java new file mode 100644 index 00000000000..8b30aeafc3e --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/DynamicSqlErrorException.java @@ -0,0 +1,34 @@ +// 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.exception; + +public class DynamicSqlErrorException extends SqlExecutionException +{ + + /* + SQL STATE: 07*** + */ + + public DynamicSqlErrorException(String message, Throwable cause, String SQLState, int vendorCode) + { + super(message, cause, SQLState, vendorCode); + } + + @Override + public boolean isRecoverable() + { + return false; + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlExecutionException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlExecutionException.java new file mode 100644 index 00000000000..7638c60b1ab --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlExecutionException.java @@ -0,0 +1,46 @@ +// 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.exception; + +import org.finos.legend.engine.persistence.components.exception.PersistenceException; + +public class SqlExecutionException extends PersistenceException +{ + private String SQLState; + private int errorCode; + + public SqlExecutionException(String message, Throwable cause, String SQLState, int errorCode) + { + super(message, cause); + this.SQLState = SQLState; + this.errorCode = errorCode; + } + + @Override + public boolean isRecoverable() + { + return false; + } + + public String getSQLState() + { + return SQLState; + } + + public int getErrorCode() + { + return errorCode; + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlExecutionExceptionMapper.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlExecutionExceptionMapper.java new file mode 100644 index 00000000000..93c01c20b56 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlExecutionExceptionMapper.java @@ -0,0 +1,53 @@ +// 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.exception; + +import java.sql.SQLException; + +public class SqlExecutionExceptionMapper +{ + public static SqlExecutionException from(SQLException sqlException) + { + String SQLState = sqlException.getSQLState(); + int errorCode = sqlException.getErrorCode(); + String classCode = getClassCode(sqlException); + + switch (classCode) + { + case "07" : return new DynamicSqlErrorException(sqlException.getMessage(), sqlException, SQLState, errorCode); + case "08" : return new ConnectionException(sqlException.getMessage(), sqlException, SQLState, errorCode); + case "20" : + case "21" : + case "22" : return new DataRelatedException(sqlException.getMessage(), sqlException, SQLState, errorCode); + case "23" : return new ConstraintViolationException(sqlException.getMessage(), sqlException, SQLState, errorCode); + case "40" : return new TransactionRollbackException(sqlException.getMessage(), sqlException, SQLState, errorCode); + case "42" : return new SqlSyntaxErrorOrAccessRuleViolationException(sqlException.getMessage(), sqlException, SQLState, errorCode); + default: return new SqlExecutionException(sqlException.getMessage(), sqlException, SQLState, errorCode); + } + } + + private static String getClassCode(SQLException sqlException) + { + try + { + String classCode = sqlException.getSQLState().substring(0, 2); + return classCode; + } + catch (Exception e) + { + throw new SqlExecutionException(sqlException.getMessage(), sqlException, sqlException.getSQLState(), sqlException.getErrorCode()); + } + } +} diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlSyntaxErrorOrAccessRuleViolationException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlSyntaxErrorOrAccessRuleViolationException.java new file mode 100644 index 00000000000..92817fd446a --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/SqlSyntaxErrorOrAccessRuleViolationException.java @@ -0,0 +1,34 @@ +// 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.exception; + +public class SqlSyntaxErrorOrAccessRuleViolationException extends SqlExecutionException +{ + + /* + SQL STATE: 42*** + */ + + public SqlSyntaxErrorOrAccessRuleViolationException(String message,Throwable cause, String SQLState, int vendorCode) + { + super(message, cause, SQLState, vendorCode); + } + + @Override + public boolean isRecoverable() + { + return false; + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/TransactionRollbackException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/TransactionRollbackException.java new file mode 100644 index 00000000000..9b3ab838473 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/exception/TransactionRollbackException.java @@ -0,0 +1,34 @@ +// 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.exception; + +public class TransactionRollbackException extends SqlExecutionException +{ + + /* + SQL STATE: 40*** + */ + + public TransactionRollbackException(String message, Throwable cause, String SQLState, int vendorCode) + { + super(message, cause, SQLState, vendorCode); + } + + @Override + public boolean isRecoverable() + { + return true; + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcHelper.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcHelper.java index 0e6c9bc0030..2031aa8cebd 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcHelper.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcHelper.java @@ -22,6 +22,7 @@ import org.finos.legend.engine.persistence.components.logicalplan.datasets.Index; import org.finos.legend.engine.persistence.components.logicalplan.datasets.SchemaDefinition; import org.finos.legend.engine.persistence.components.executor.RelationalExecutionHelper; +import org.finos.legend.engine.persistence.components.relational.exception.SqlExecutionExceptionMapper; import org.finos.legend.engine.persistence.components.relational.sql.DataTypeMapping; import org.finos.legend.engine.persistence.components.relational.sql.JdbcPropertiesToLogicalDataTypeMapping; import org.finos.legend.engine.persistence.components.relational.sqldom.common.Clause; @@ -90,7 +91,7 @@ public void beginTransaction() } catch (SQLException e) { - throw new RuntimeException(e); + throw SqlExecutionExceptionMapper.from(e); } } @@ -105,7 +106,7 @@ public void commitTransaction() } catch (SQLException e) { - throw new RuntimeException(e); + throw SqlExecutionExceptionMapper.from(e); } } } @@ -121,7 +122,7 @@ public void revertTransaction() } catch (SQLException e) { - throw new RuntimeException(e); + throw SqlExecutionExceptionMapper.from(e); } } } @@ -137,7 +138,7 @@ public void closeTransactionManager() } catch (SQLException e) { - throw new RuntimeException(e); + throw SqlExecutionExceptionMapper.from(e); } finally { @@ -159,7 +160,7 @@ public boolean doesTableExist(Dataset dataset) } catch (SQLException e) { - throw new RuntimeException(e); + throw SqlExecutionExceptionMapper.from(e); } } @@ -254,7 +255,7 @@ public void validateDatasetSchema(Dataset dataset, TypeMapping typeMapping) } catch (SQLException e) { - throw new RuntimeException(e); + throw SqlExecutionExceptionMapper.from(e); } } @@ -359,7 +360,7 @@ public Dataset constructDatasetFromDatabase(Dataset dataset, TypeMapping typeMap catch (SQLException e) { LOGGER.error("Exception in Constructing dataset Schema from Database", e); - throw new RuntimeException(e); + throw SqlExecutionExceptionMapper.from(e); } } @@ -428,7 +429,7 @@ public void executeStatements(List sqls) } catch (SQLException e) { - throw new RuntimeException(e); + throw SqlExecutionExceptionMapper.from(e); } } else @@ -444,20 +445,16 @@ public void executeStatements(List sqls) } txManager.commitTransaction(); } + catch (SQLException e) + { + LOGGER.error("SQLException executing SQL statements: " + sqls, e); + revertTransaction(txManager); + throw SqlExecutionExceptionMapper.from(e); + } catch (Exception e) { - LOGGER.error("Error executing SQL statements: " + sqls, e); - if (txManager != null) - { - try - { - txManager.revertTransaction(); - } - catch (SQLException e2) - { - throw new RuntimeException(e2); - } - } + LOGGER.error("Exception executing SQL statements: " + sqls, e); + revertTransaction(txManager); throw new RuntimeException(e); } finally @@ -477,12 +474,34 @@ public void executeStatements(List sqls) } } + private void revertTransaction(JdbcTransactionManager txManager) + { + if (txManager != null) + { + try + { + txManager.revertTransaction(); + } + catch (SQLException e) + { + throw SqlExecutionExceptionMapper.from(e); + } + } + } + @Override public List> executeQuery(String sql, int rows) { if (this.transactionManager != null) { - return this.transactionManager.convertResultSetToList(sql, rows); + try + { + return this.transactionManager.convertResultSetToList(sql, rows); + } + catch (SQLException e) + { + throw SqlExecutionExceptionMapper.from(e); + } } else { @@ -492,9 +511,9 @@ public List> executeQuery(String sql, int rows) txManager = new JdbcTransactionManager(connection); return txManager.convertResultSetToList(sql, rows); } - catch (Exception e) + catch (SQLException e) { - throw new RuntimeException("Error executing SQL query: " + sql, e); + throw SqlExecutionExceptionMapper.from(e); } finally { @@ -518,7 +537,14 @@ public List> executeQuery(String sql) { if (this.transactionManager != null) { - return this.transactionManager.convertResultSetToList(sql); + try + { + return this.transactionManager.convertResultSetToList(sql); + } + catch (SQLException e) + { + throw SqlExecutionExceptionMapper.from(e); + } } else { @@ -528,9 +554,9 @@ public List> executeQuery(String sql) txManager = new JdbcTransactionManager(connection); return txManager.convertResultSetToList(sql); } - catch (Exception e) + catch (SQLException e) { - throw new RuntimeException("Error executing SQL query: " + sql, e); + throw SqlExecutionExceptionMapper.from(e); } finally { diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcTransactionManager.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcTransactionManager.java index 464f3d28605..e0d789b9323 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcTransactionManager.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcTransactionManager.java @@ -77,46 +77,32 @@ public boolean executeInCurrentTransaction(String sql) throws SQLException } // todo: find a better way to return both the data and schema - public List> convertResultSetToList(String sql) + public List> convertResultSetToList(String sql) throws SQLException { - try + List> resultList = new ArrayList<>(); + try (ResultSet resultSet = this.statement.executeQuery(sql)) { - List> resultList = new ArrayList<>(); - try (ResultSet resultSet = this.statement.executeQuery(sql)) + while (resultSet.next()) { - while (resultSet.next()) - { - extractResults(resultList, resultSet); - } + extractResults(resultList, resultSet); } - return resultList; - } - catch (SQLException e) - { - throw new RuntimeException(e); } + return resultList; } - public List> convertResultSetToList(String sql, int rows) + public List> convertResultSetToList(String sql, int rows) throws SQLException { - try + List> resultList = new ArrayList<>(); + try (ResultSet resultSet = this.statement.executeQuery(sql)) { - List> resultList = new ArrayList<>(); - try (ResultSet resultSet = this.statement.executeQuery(sql)) + int iter = 0; + while (resultSet.next() && iter < rows) { - int iter = 0; - while (resultSet.next() && iter < rows) - { - iter++; - extractResults(resultList, resultSet); - } + iter++; + extractResults(resultList, resultSet); } - return resultList; - } - catch (SQLException e) - { - throw new RuntimeException(e); } + return resultList; } private static void extractResults(List> resultList, ResultSet resultSet) throws SQLException diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sqldom/SqlDomException.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sqldom/SqlDomException.java index f2528b341f4..937cf7f751c 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sqldom/SqlDomException.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sqldom/SqlDomException.java @@ -14,9 +14,17 @@ package org.finos.legend.engine.persistence.components.relational.sqldom; -public class SqlDomException extends RuntimeException +import org.finos.legend.engine.persistence.components.exception.PersistenceException; + +public class SqlDomException extends PersistenceException { + @Override + public boolean isRecoverable() + { + return false; + } + public SqlDomException(String e) { super(e); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/main/java/org/finos/legend/engine/persistence/components/relational/h2/logicalplan/datasets/H2StagedFilesDatasetPropertiesAbstract.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/main/java/org/finos/legend/engine/persistence/components/relational/h2/logicalplan/datasets/H2StagedFilesDatasetPropertiesAbstract.java index f067057cd10..6e00c386d76 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/main/java/org/finos/legend/engine/persistence/components/relational/h2/logicalplan/datasets/H2StagedFilesDatasetPropertiesAbstract.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/main/java/org/finos/legend/engine/persistence/components/relational/h2/logicalplan/datasets/H2StagedFilesDatasetPropertiesAbstract.java @@ -37,15 +37,15 @@ default void validate() { if (filePatterns().size() > 0) { - throw new IllegalArgumentException("Cannot build H2StagedFilesDatasetProperties, filePatterns not supported"); + throw new IllegalStateException("Cannot build H2StagedFilesDatasetProperties, filePatterns not supported"); } if (filePaths().size() != 1) { - throw new IllegalArgumentException("Cannot build H2StagedFilesDatasetProperties, only 1 file per load supported"); + throw new IllegalStateException("Cannot build H2StagedFilesDatasetProperties, only 1 file per load supported"); } if (fileFormat() != FileFormatType.CSV) { - throw new IllegalArgumentException("Cannot build H2StagedFilesDatasetProperties, only CSV file loading supported"); + throw new IllegalStateException("Cannot build H2StagedFilesDatasetProperties, only CSV file loading supported"); } } } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/SnowflakeSink.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/SnowflakeSink.java index 9d9619ad279..e025943e74c 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/SnowflakeSink.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/SnowflakeSink.java @@ -22,6 +22,7 @@ import org.finos.legend.engine.persistence.components.common.Datasets; import org.finos.legend.engine.persistence.components.common.FileFormatType; import org.finos.legend.engine.persistence.components.common.StatisticName; +import org.finos.legend.engine.persistence.components.exception.JsonReadOrWriteException; import org.finos.legend.engine.persistence.components.executor.Executor; import org.finos.legend.engine.persistence.components.logicalplan.LogicalPlan; import org.finos.legend.engine.persistence.components.logicalplan.LogicalPlanFactory; @@ -584,7 +585,7 @@ private String getErrorMessage(Map row) } catch (JsonProcessingException e) { - throw new RuntimeException(e); + throw new JsonReadOrWriteException(e.getMessage(), e); } } }