This is an automated email from the ASF dual-hosted git repository.
zstan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 5c81840191 IGNITE-20889 Sql. Remove extra coercion code (#4297)
5c81840191 is described below
commit 5c818401915e1b306c3c0e20a0d2a6a9c28de0df
Author: Evgeniy Stanilovskiy <[email protected]>
AuthorDate: Mon Sep 2 08:19:32 2024 +0300
IGNITE-20889 Sql. Remove extra coercion code (#4297)
---
.../internal/sql/engine/ItDataTypesTest.java | 6 ++--
.../integrationTest/sql/cast/test_cast_bigint.test | 12 +++----
.../sql/engine/prepare/IgniteSqlValidator.java | 41 ----------------------
.../sql/engine/prepare/IgniteTypeCoercion.java | 8 -----
4 files changed, 8 insertions(+), 59 deletions(-)
diff --git
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDataTypesTest.java
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDataTypesTest.java
index 3efeb32a36..8757fde871 100644
---
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDataTypesTest.java
+++
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDataTypesTest.java
@@ -233,10 +233,8 @@ public class ItDataTypesTest extends
BaseSqlIntegrationTest {
assertQuery(format("SELECT * FROM tbl WHERE v NOT IN ('{}' - '1',
'0')", strUpper)).returns(checkReturn).check();
assertQuery("SELECT * FROM tbl WHERE v NOT IN (? - '1',
'0')").withParam(checkReturn).returns(checkReturn).check();
- // TODO: https://issues.apache.org/jira/browse/IGNITE-20889
- // Sql. Change type derivation for literals and expressions for
overflowed BIGINT
- // BigDecimal moreThanUpperBoundExact = new
BigDecimal(strUpper).add(new BigDecimal(1));
- // assertQuery(format("SELECT * FROM tbl WHERE v < {}::DECIMAL(19,
0)", moreThanUpperBoundExact)).returns(checkReturn).check();
+ BigDecimal moreThanUpperBoundExact = new BigDecimal(strUpper).add(new
BigDecimal(1));
+ assertQuery(format("SELECT * FROM tbl WHERE v < {}::DECIMAL(19, 0)",
moreThanUpperBoundExact)).returns(checkReturn).check();
assertQuery("SELECT * FROM tbl WHERE v >
OCTET_LENGTH('TEST')").returns(checkReturn).check();
assertQuery(format("SELECT NULLIF((select {}), 100)",
moreThanUpperBoundApprox))
diff --git
a/modules/sql-engine/src/integrationTest/sql/cast/test_cast_bigint.test
b/modules/sql-engine/src/integrationTest/sql/cast/test_cast_bigint.test
index f23f245bf0..33e8923613 100644
--- a/modules/sql-engine/src/integrationTest/sql/cast/test_cast_bigint.test
+++ b/modules/sql-engine/src/integrationTest/sql/cast/test_cast_bigint.test
@@ -6,20 +6,20 @@
statement ok
SELECT CAST('100' AS BIGINT);
-# https://issues.apache.org/jira/browse/IGNITE-20889
-skipif ignite3
-statement error
+query T
SELECT CAST('100.1' AS BIGINT);
+----
+100
query T
SELECT CAST(1e1 AS BIGINT);
----
10
-# https://issues.apache.org/jira/browse/IGNITE-20889
-skipif ignite3
-statement error: For input string: "1e2"
+query T
SELECT CAST('1e2' AS BIGINT);
+----
+100
# overflow
statement error
diff --git
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteSqlValidator.java
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteSqlValidator.java
index 5b0dac090a..4505855de9 100644
---
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteSqlValidator.java
+++
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteSqlValidator.java
@@ -235,47 +235,6 @@ public class IgniteSqlValidator extends SqlValidatorImpl {
syncSelectList(select, call);
}
- /** {@inheritDoc} */
- @Override
- protected void checkTypeAssignment(
- SqlValidatorScope sourceScope,
- SqlValidatorTable table,
- RelDataType sourceRowType,
- RelDataType targetRowType,
- SqlNode query
- ) {
- boolean coerced = false;
-
- if (query instanceof SqlUpdate) {
- SqlNodeList targetColumnList =
- requireNonNull(((SqlUpdate) query).getTargetColumnList());
- int targetColumnCount = targetColumnList.size();
- targetRowType =
- SqlTypeUtil.extractLastNFields(typeFactory, targetRowType,
- targetColumnCount);
- sourceRowType =
- SqlTypeUtil.extractLastNFields(typeFactory, sourceRowType,
- targetColumnCount);
- }
-
- // if BIGINT is present we need to preserve CAST from BIGINT to BIGINT
for further overflow check possibility
- // TODO: need to be removed after
https://issues.apache.org/jira/browse/IGNITE-20889
- if (config().typeCoercionEnabled()) {
- if (SqlTypeUtil.equalAsStructSansNullability(typeFactory,
- sourceRowType, targetRowType, null)) {
- if ((query.getKind() == SqlKind.INSERT || query.getKind() ==
SqlKind.UPDATE)
- && targetRowType.getFieldList().stream().anyMatch(fld
-> fld.getType().getSqlTypeName() == SqlTypeName.BIGINT)
- && sourceRowType.getFieldList().stream().anyMatch(fld
-> fld.getType().getSqlTypeName() == SqlTypeName.BIGINT)) {
- coerced =
getTypeCoercion().querySourceCoercion(sourceScope, sourceRowType,
targetRowType, query);
- }
- }
- }
-
- if (!coerced) {
- doCheckTypeAssignment(sourceScope, table, sourceRowType,
targetRowType, query);
- }
- }
-
/** {@inheritDoc} */
@Override
public void validateMerge(SqlMerge call) {
diff --git
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteTypeCoercion.java
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteTypeCoercion.java
index b70888eed8..f13461ceb5 100644
---
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteTypeCoercion.java
+++
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteTypeCoercion.java
@@ -308,14 +308,6 @@ public class IgniteTypeCoercion extends TypeCoercionImpl {
if (fromType == null) {
return false;
}
-
- // we need this check for further possibility to validate BIGINT
overflow
- // TODO: need to be removed after
https://issues.apache.org/jira/browse/IGNITE-20889
- if (fromType.getSqlTypeName() == SqlTypeName.BIGINT &&
toType.getSqlTypeName() == SqlTypeName.BIGINT) {
- if (node.getKind() == SqlKind.LITERAL) {
- return true;
- }
- }
// The following checks ensure that there no ClassCastException
when casting from one
// integer type to another (e.g. int to smallint, int to bigint)
if (SqlTypeUtil.isIntType(fromType) && fromType.getSqlTypeName()
!= toType.getSqlTypeName()) {