You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "mihaibudiu (via GitHub)" <gi...@apache.org> on 2024/10/29 21:44:00 UTC
[PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
mihaibudiu opened a new pull request, #4024:
URL: https://github.com/apache/calcite/pull/4024
The bug fixed is the following:
In a set operation (UNION, INTERSECTION, EXCEPT) the participating relations are supposed to have the same columns with the same types. The type of the result is inferred to be the wider of the participating types. This is correct.
However, the types of the operands participating in the set operations need to be coerced to the output type. This part was missing.
The fix has two parts:
- in SetopOperandsTypeChecker the missing coercion has been introduced (the code was there, but wasn't called in most cases)
- in AbstractTypeCoercion a check for useless casts has been strengthened. The comments on the check were right, but the implementation was wrong.
The complete fix is only a few lines of code, but... unfortunately this change leads to many test failures, which had to be patched, 63 at my count. Some of the tests are obviously wrong, while the other are more subtle. I had to disable a couple which I couldn't actually fix (not because the results are wrong, but because the condition they were testing is no longer present in the test).
Many tests that contain plans are very hard for humans to evaluate for correctness.
I also had to change the typeSystem of BigQuery to use raggedUnionTypesToVarying, from empirical testing this seems to be right. (In fact, I suspect other dialects also needs this change, the default in Calcite is the opposite, which is very weird).
This may also seemingly degrade the quality of some query plans, because they will contain casts that were not there previously. Unfortunately, these plans were wrong.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1824787569
##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -274,9 +274,10 @@ protected boolean needToCast(SqlValidatorScope scope, SqlNode node,
return false;
}
- // No need to cast between char and varchar.
+ // No need to cast between char and unlimited varchar.
if (SqlTypeUtil.isCharacter(toType)
- && SqlTypeUtil.isCharacter(fromType)) {
+ && SqlTypeUtil.isCharacter(fromType)
+ && toType.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED) {
Review Comment:
@mihaibudiu `Character`includes char, varchar, longvarchar, blob. Are these what you want? Will this have any impact?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4024:
URL: https://github.com/apache/calcite/pull/4024#issuecomment-2456206856
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4024) **Quality Gate passed**
Issues
 [7 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4024&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4024&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4024&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4024&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4024&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4024)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1826096772
##########
core/src/test/java/org/apache/calcite/test/RelMetadataTest.java:
##########
@@ -405,7 +405,8 @@ final RelMetadataFixture sql(String sql) {
.assertColumnOriginIsEmpty();
}
- @Test void testColumnOriginsUnion() {
+ @Test @Disabled("Plan contains casts, which inhibit metadata propagation")
Review Comment:
I could interpret your question in two ways:
- should metadata be propagated when a column has a cast?
- should we create a different test for metadata propagation?
The second one is a bit easier to do.
For the first one, I don't know the answer. If the answer is "yes", we should create an issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1828380316
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -7777,7 +7777,7 @@ private void checkLiteral2(String expression, String expected) {
final String expectedDefault = "INSERT INTO \"SCOTT\".\"DEPT\""
+ " (\"DEPTNO\", \"DNAME\", \"LOC\")\n"
+ "VALUES (1, 'Fred', 'San Francisco'),\n"
- + "(2, 'Eric', 'Washington ')";
Review Comment:
The types of these fields in the Scott database is actually VARCHAR(20), and VARCHAR types are not supposed to store the padding spaces, unlike CHAR(N) types. So the result is correct. I don't know exactly why the result was wrong before.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1824556732
##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -274,9 +274,10 @@ protected boolean needToCast(SqlValidatorScope scope, SqlNode node,
return false;
}
- // No need to cast between char and varchar.
+ // No need to cast between char and unlimited varchar.
if (SqlTypeUtil.isCharacter(toType)
- && SqlTypeUtil.isCharacter(fromType)) {
+ && SqlTypeUtil.isCharacter(fromType)
+ && toType.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED) {
Review Comment:
Why do we need to judge precision?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4024:
URL: https://github.com/apache/calcite/pull/4024#issuecomment-2452621903
Unfortunately this interferes negatively with the fix for https://issues.apache.org/jira/browse/CALCITE-4590, so more work will be needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4024:
URL: https://github.com/apache/calcite/pull/4024#issuecomment-2452406788
@NobiGo I have filed https://github.com/apache/calcite/pull/4028 with a fix for https://issues.apache.org/jira/browse/CALCITE-4590. It is a completely different bug.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1826104036
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -4395,7 +4395,7 @@ private SqlDialect nonOrdinalDialect() {
+ "FROM (SELECT \"product_id\", \"net_weight\"\n"
+ "FROM \"foodmart\".\"product\"\n"
+ "UNION ALL\n"
- + "SELECT \"product_id\", 0 AS \"net_weight\"\n"
+ + "SELECT \"product_id\", 0E0 AS \"net_weight\"\n"
Review Comment:
Yes, this is necessary, since now the 0 constant is cast to the type of net_weight, which is double.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1824787569
##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -274,9 +274,10 @@ protected boolean needToCast(SqlValidatorScope scope, SqlNode node,
return false;
}
- // No need to cast between char and varchar.
+ // No need to cast between char and unlimited varchar.
if (SqlTypeUtil.isCharacter(toType)
- && SqlTypeUtil.isCharacter(fromType)) {
+ && SqlTypeUtil.isCharacter(fromType)
+ && toType.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED) {
Review Comment:
`Character`includes char, varchar, longvarchar. Are these what you want?
<img width="321" alt="image" src="https://github.com/user-attachments/assets/ef381dbb-c98e-4035-8b16-aba10a1bfb1f">
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1824777408
##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -274,9 +274,10 @@ protected boolean needToCast(SqlValidatorScope scope, SqlNode node,
return false;
}
- // No need to cast between char and varchar.
+ // No need to cast between char and unlimited varchar.
if (SqlTypeUtil.isCharacter(toType)
- && SqlTypeUtil.isCharacter(fromType)) {
+ && SqlTypeUtil.isCharacter(fromType)
+ && toType.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED) {
Review Comment:
In SQL VARCHAR and VARCHAR(N) are very different types.
This is checking for VARCHAR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1824787569
##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -274,9 +274,10 @@ protected boolean needToCast(SqlValidatorScope scope, SqlNode node,
return false;
}
- // No need to cast between char and varchar.
+ // No need to cast between char and unlimited varchar.
if (SqlTypeUtil.isCharacter(toType)
- && SqlTypeUtil.isCharacter(fromType)) {
+ && SqlTypeUtil.isCharacter(fromType)
+ && toType.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED) {
Review Comment:
`Character`includes char, varchar, longvarchar. Are these what you want?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4024:
URL: https://github.com/apache/calcite/pull/4024#issuecomment-2452687202
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4024) **Quality Gate passed**
Issues
 [7 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4024&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4024&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4024&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4024&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4024&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4024)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4024:
URL: https://github.com/apache/calcite/pull/4024#issuecomment-2452666016
I have found one more bug in the implementation of casts, where casts from VARCHAR(N) to CHAR(N) for the same N were essentially ignored. This is wrong, because VARCHAR(N) does not store the trailing spaces, whereas CHAR(N) needs to store them.
With this change, which I added in an extra commit, hopefully the tests will pass again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #4024:
URL: https://github.com/apache/calcite/pull/4024
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4024:
URL: https://github.com/apache/calcite/pull/4024#issuecomment-2452322089
Unfortunately this does not solve https://issues.apache.org/jira/browse/CALCITE-4590, since that is about OR, not about UNION.
I can take a look at that problem as well in a separate PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1824787569
##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -274,9 +274,10 @@ protected boolean needToCast(SqlValidatorScope scope, SqlNode node,
return false;
}
- // No need to cast between char and varchar.
+ // No need to cast between char and unlimited varchar.
if (SqlTypeUtil.isCharacter(toType)
- && SqlTypeUtil.isCharacter(fromType)) {
+ && SqlTypeUtil.isCharacter(fromType)
+ && toType.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED) {
Review Comment:
@caicancai `Character`includes char, varchar, longvarchar. Are these what you want?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4024:
URL: https://github.com/apache/calcite/pull/4024#issuecomment-2453775677
I am thinking to merge this with 2 commits, since the second commit solves an independent bug....
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #4024:
URL: https://github.com/apache/calcite/pull/4024#issuecomment-2453857480
> I am thinking to merge this with 2 commits, since the second commit solves an independent bug....
Agreed, but it's not clear to me whether to create a jira case for the second commit
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1826866273
##########
server/src/test/resources/sql/materialized_view.iq:
##########
@@ -39,12 +39,12 @@ select * from dept where deptno > 10;
# Check contents
select * from v;
-+--------+-------------+
-| DEPTNO | NAME |
-+--------+-------------+
-| 20 | Marketing |
-| 30 | Engineering |
Review Comment:
The changes here are a bit strange. Maybe we can change the table definition statement.
```
# Create a source table
create table dept (deptno int not null, name varchar(10));
(0 rows modified)
!update
insert into dept
values (10, 'Sales'), (20, 'Marketing'), (30, 'Engineering');
(3 rows modified)
```
According to the output content, was cropping done during output or input?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1823813631
##########
core/src/test/java/org/apache/calcite/test/RelMetadataTest.java:
##########
@@ -405,7 +405,8 @@ final RelMetadataFixture sql(String sql) {
.assertColumnOriginIsEmpty();
}
- @Test void testColumnOriginsUnion() {
+ @Test @Disabled("Plan contains casts, which inhibit metadata propagation")
Review Comment:
Do we need to create issue for this?
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -4395,7 +4395,7 @@ private SqlDialect nonOrdinalDialect() {
+ "FROM (SELECT \"product_id\", \"net_weight\"\n"
+ "FROM \"foodmart\".\"product\"\n"
+ "UNION ALL\n"
- + "SELECT \"product_id\", 0 AS \"net_weight\"\n"
+ + "SELECT \"product_id\", 0E0 AS \"net_weight\"\n"
Review Comment:
This is necessary?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1827033808
##########
server/src/test/resources/sql/materialized_view.iq:
##########
@@ -39,12 +39,12 @@ select * from dept where deptno > 10;
# Check contents
select * from v;
-+--------+-------------+
-| DEPTNO | NAME |
-+--------+-------------+
-| 20 | Marketing |
-| 30 | Engineering |
Review Comment:
I actually don't know how insert is implemented in Calcite.
But no matter what, the result is now correct, and it wasn't before.
So I think this is actually a good test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1827085300
##########
server/src/test/resources/sql/materialized_view.iq:
##########
@@ -39,12 +39,12 @@ select * from dept where deptno > 10;
# Check contents
select * from v;
-+--------+-------------+
-| DEPTNO | NAME |
-+--------+-------------+
-| 20 | Marketing |
-| 30 | Engineering |
Review Comment:
Ok. I get it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "suibianwanwank (via GitHub)" <gi...@apache.org>.
suibianwanwank commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1827700697
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -7777,7 +7777,7 @@ private void checkLiteral2(String expression, String expected) {
final String expectedDefault = "INSERT INTO \"SCOTT\".\"DEPT\""
+ " (\"DEPTNO\", \"DNAME\", \"LOC\")\n"
+ "VALUES (1, 'Fred', 'San Francisco'),\n"
- + "(2, 'Eric', 'Washington ')";
Review Comment:
Is this the expected result, char type value in calcite seem to require aligned lengths.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1824811903
##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -274,9 +274,10 @@ protected boolean needToCast(SqlValidatorScope scope, SqlNode node,
return false;
}
- // No need to cast between char and varchar.
+ // No need to cast between char and unlimited varchar.
if (SqlTypeUtil.isCharacter(toType)
- && SqlTypeUtil.isCharacter(fromType)) {
+ && SqlTypeUtil.isCharacter(fromType)
+ && toType.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED) {
Review Comment:
clearly, the original code is wrong. The comment says "varchar", but the code does not check for varchar. Here I have made the code match the comment, which seems correct. I haven't investigated what happens to binary objects. It's possible that this check is still not strong enough, but it is certainly better than it was, and it fixes the problem reported.
In general, when fixing a bug, I am trying to make the minimal changes necessary to solve the problem reported, without breaking anything else. Calcite is very complex, as you can see, even a small change may affect lots of tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6350] Unexpected result from UNION with literals expression [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4024:
URL: https://github.com/apache/calcite/pull/4024#issuecomment-2445421204
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4024) **Quality Gate passed**
Issues
 [5 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4024&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4024&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4024&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4024&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4024&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4024)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org