Skip to content

Commit

Permalink
Refactor SQLFederationSQLException (#30823)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Apr 9, 2024
1 parent be22e42 commit fdcd62d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| 20088 | 44000 | Cannot found routing table factor, data source: %s, actual table: %s. |
| 20090 | 42000 | Not allow DML operation without sharding conditions. |

### 联邦查询

| Vendor Code | SQL State | 错误信息 |
|-------------|-----------|---------------------------------------------------------|
| 20100 | 42000 | Unsupported SQL node conversion for SQL statement '%s'. |
| 20101 | 42000 | SQL federation does not support SQL '%s'. |

### 读写分离

| Vendor Code | SQL State | 错误信息 |
Expand Down Expand Up @@ -235,13 +242,6 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| 20840 | 42000 | Insert value of index \`%s\` can not support for shadow. |
| 20881 | 44000 | Default shadow algorithm class should be implement HintShadowAlgorithm. |

### 联邦查询

| Vendor Code | SQL State | 错误信息 |
|-------------|-----------|-----------------------------------------------------------|
| 22040 | 42000 | Unsupported SQL node conversion for SQL statement \`%s\`. |
| 22041 | 42000 | SQL federation doesn't support SQL \`%s\` execution. |

## 其他异常

| Vendor Code | SQL State | 错误信息 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| 20088 | 44000 | Cannot found routing table factor, data source: %s, actual table: %s. |
| 20090 | 42000 | Not allow DML operation without sharding conditions. |

### SQL Federation

| Vendor Code | SQL State | Reason |
|-------------|-----------|---------------------------------------------------------|
| 20100 | 42000 | Unsupported SQL node conversion for SQL statement '%s'. |
| 20101 | 42000 | SQL federation does not support SQL '%s'. |

### Readwrite-splitting

| Vendor Code | SQL State | Reason |
Expand Down Expand Up @@ -236,13 +243,6 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| 20840 | 42000 | Insert value of index \`%s\` can not support for shadow. |
| 20881 | 44000 | Default shadow algorithm class should be implement HintShadowAlgorithm. |

### SQL Federation

| Vendor Code | SQL State | Reason |
|-------------|-----------|-----------------------------------------------------------|
| 22040 | 42000 | Unsupported SQL node conversion for SQL statement \`%s\`. |
| 22041 | 42000 | SQL federation doesn't support SQL \`%s\` execution. |

## Other Exception

| Vendor Code | SQL State | Reason |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import org.apache.shardingsphere.sqlfederation.optimizer.SQLFederationExecutionPlan;
import org.apache.shardingsphere.sqlfederation.optimizer.context.OptimizerContext;
import org.apache.shardingsphere.sqlfederation.optimizer.context.planner.OptimizerMetaData;
import org.apache.shardingsphere.sqlfederation.optimizer.exception.syntax.SQLFederationUnsupportedSQLException;
import org.apache.shardingsphere.sqlfederation.optimizer.exception.SQLFederationUnsupportedSQLException;
import org.apache.shardingsphere.sqlfederation.optimizer.metadata.schema.SQLFederationTable;
import org.apache.shardingsphere.sqlfederation.optimizer.planner.cache.ExecutionPlanCacheKey;
import org.apache.shardingsphere.sqlfederation.optimizer.planner.util.SQLFederationPlannerUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.apache.shardingsphere.sqlfederation.optimizer.converter.statement.merge.MergeStatementConverter;
import org.apache.shardingsphere.sqlfederation.optimizer.converter.statement.select.SelectStatementConverter;
import org.apache.shardingsphere.sqlfederation.optimizer.converter.statement.update.UpdateStatementConverter;
import org.apache.shardingsphere.sqlfederation.optimizer.exception.convert.OptimizationSQLNodeConvertException;
import org.apache.shardingsphere.sqlfederation.optimizer.exception.OptimizationSQLNodeConvertException;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
* limitations under the License.
*/

package org.apache.shardingsphere.sqlfederation.optimizer.exception.convert;
package org.apache.shardingsphere.sqlfederation.optimizer.exception;

import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sqlfederation.optimizer.exception.SQLFederationSQLException;

/**
* Optimization SQL node convert exception.
Expand All @@ -29,6 +28,6 @@ public final class OptimizationSQLNodeConvertException extends SQLFederationSQLE
private static final long serialVersionUID = 7115939407266382363L;

public OptimizationSQLNodeConvertException(final SQLStatement statement) {
super(XOpenSQLState.SYNTAX_ERROR, 40, "Unsupported SQL node conversion for SQL statement `%s`.", statement.toString());
super(XOpenSQLState.SYNTAX_ERROR, 0, "Unsupported SQL node conversion for SQL statement '%s'.", statement);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class SQLFederationSQLException extends FeatureSQLException {

private static final long serialVersionUID = 4689889693356895996L;

private static final int FEATURE_CODE = 20;
private static final int FEATURE_CODE = 1;

protected SQLFederationSQLException(final SQLState sqlState, final int errorCode, final String reason, final Object... messageArgs) {
super(sqlState, FEATURE_CODE, errorCode, reason, messageArgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
* limitations under the License.
*/

package org.apache.shardingsphere.sqlfederation.optimizer.exception.syntax;
package org.apache.shardingsphere.sqlfederation.optimizer.exception;

import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
import org.apache.shardingsphere.sqlfederation.optimizer.exception.SQLFederationSQLException;

/**
* SQL federation unsupported SQL exception.
Expand All @@ -28,6 +27,6 @@ public final class SQLFederationUnsupportedSQLException extends SQLFederationSQL
private static final long serialVersionUID = -8571244162760408846L;

public SQLFederationUnsupportedSQLException(final String sql) {
super(XOpenSQLState.SYNTAX_ERROR, 41, "SQL federation doesn't support SQL `%s` execution.", sql);
super(XOpenSQLState.SYNTAX_ERROR, 1, "SQL federation does not support SQL '%s'.", sql);
}
}

0 comments on commit fdcd62d

Please sign in to comment.