You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "caicancai (via GitHub)" <gi...@apache.org> on 2024/07/06 13:27:36 UTC
[PR] [CALCITE-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapV…auleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
caicancai opened a new pull request, #3847:
URL: https://github.com/apache/calcite/pull/3847
(no comment)
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapV…auleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3847:
URL: https://github.com/apache/calcite/pull/3847#issuecomment-2211769198
https://issues.apache.org/jira/browse/CALCITE-6300
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3847:
URL: https://github.com/apache/calcite/pull/3847#issuecomment-2358288571
@rubenada Looks like my local git crashed for me, I will open a new 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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3847:
URL: https://github.com/apache/calcite/pull/3847#issuecomment-2227181301
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3847) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3847&resolved=false&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3847&resolutions=WONTFIX)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3847&resolved=false&sinceLeakPeriod=true)
 [92.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3847&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3847&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3847)
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3847:
URL: https://github.com/apache/calcite/pull/3847#issuecomment-2211772420
I think I can encapsulate a unified interface during parameter verification to convert all spark map functions
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3847:
URL: https://github.com/apache/calcite/pull/3847#discussion_r1764896546
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -1532,6 +1532,7 @@ private static class MapKeyOperandTypeChecker extends SameOperandTypeChecker {
}
}
+
Review Comment:
Thanks for your review, I will fix it and resolve the conflict tonight
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3847:
URL: https://github.com/apache/calcite/pull/3847#discussion_r1676975122
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -1491,6 +1496,43 @@ private static class PeriodOperandTypeChecker
}
}
+ /**
+ * Parameter type-checking strategy where types must be Map
+ * and adjust their types to suit the Map function's constructor.
+ */
+ private static class MapSparkFunctionOperandTypeChecker extends SameOperandTypeChecker {
+ MapSparkFunctionOperandTypeChecker() {
+ super(1);
+ }
+
+ @Override public boolean checkOperandTypes(
+ SqlCallBinding callBinding,
+ boolean throwOnFailure) {
+
+ final SqlNode op0 = callBinding.operand(0);
+ if (!OperandTypes.MAP.checkSingleOperandType(
+ callBinding,
+ op0,
+ 0,
+ throwOnFailure)) {
+ return false;
+ }
+
+ final RelDataType mapKeyType =
+ getKeyTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+ final RelDataType mapValueType =
+ getValueTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+
+ // If the key and value types are not unknown,
+ // adjust their types to suit the Map function's constructor.
+ if (mapKeyType.getSqlTypeName() != SqlTypeName.UNKNOWN
Review Comment:
As Julian said in the Jira comments, you should insert casts during validation, before type checking.
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on PR #3847:
URL: https://github.com/apache/calcite/pull/3847#issuecomment-2358217136
@mihaibudiu do you have further comments here? IMO the proposed solution seems a bit ad-hoc, but seems to do the trick (and the new code is very well located). Shall we consider this for 1.38? (after resolving conflicts, squashing commits, etc.)
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3847:
URL: https://github.com/apache/calcite/pull/3847#issuecomment-2226926484
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3847) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3847&resolved=false&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3847&resolutions=WONTFIX)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3847&resolved=false&sinceLeakPeriod=true)
 [89.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3847&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3847&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3847)
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3847:
URL: https://github.com/apache/calcite/pull/3847#discussion_r1676829780
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -1491,6 +1496,43 @@ private static class PeriodOperandTypeChecker
}
}
+ /**
+ * Parameter type-checking strategy where types must be Map
+ * and adjust their types to suit the Map function's constructor.
+ */
+ private static class MapSparkFunctionOperandTypeChecker extends SameOperandTypeChecker {
+ MapSparkFunctionOperandTypeChecker() {
+ super(1);
+ }
+
+ @Override public boolean checkOperandTypes(
+ SqlCallBinding callBinding,
+ boolean throwOnFailure) {
+
+ final SqlNode op0 = callBinding.operand(0);
+ if (!OperandTypes.MAP.checkSingleOperandType(
+ callBinding,
+ op0,
+ 0,
+ throwOnFailure)) {
+ return false;
+ }
+
+ final RelDataType mapKeyType =
+ getKeyTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+ final RelDataType mapValueType =
+ getValueTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+
+ // If the key and value types are not unknown,
+ // adjust their types to suit the Map function's constructor.
+ if (mapKeyType.getSqlTypeName() != SqlTypeName.UNKNOWN
Review Comment:
Sorry for the late reply, I was sick these days.
Currently, this type check is specially prepared for Spark's map function, but there may be some problems that are difficult to eliminate as you said. However, Spark currently performs some type conversions during parameter checking. I have to admit that Spark does not do this very well.
I believe that after I have a deeper understanding of Calcite and the type system in the future, I can improve this part. I hope that day will not be too far away.
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3847:
URL: https://github.com/apache/calcite/pull/3847#discussion_r1676829343
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8182,6 +8182,19 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) {
"CHAR(3) NOT NULL ARRAY NOT NULL");
f1.checkScalar("map_keys(map('foo', 1, null, 2))", "[foo, null]",
"CHAR(3) ARRAY NOT NULL");
+
+ f1.checkScalar("map_keys(map('foo', 1, null, 2))", "[foo, null]",
Review Comment:
done, I tested all versions after spark3.4
##########
core/src/main/java/org/apache/calcite/sql/type/NonNullableAccessors.java:
##########
@@ -58,4 +58,10 @@ public static RelDataType getKeyTypeOrThrow(RelDataType type) {
return requireNonNull(type.getKeyType(),
() -> "keyType is null for " + type);
}
+
+ @API(since = "1.37", status = API.Status.EXPERIMENTAL)
Review Comment:
done
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #3847:
URL: https://github.com/apache/calcite/pull/3847#discussion_r1764883052
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -1532,6 +1532,7 @@ private static class MapKeyOperandTypeChecker extends SameOperandTypeChecker {
}
}
+
Review Comment:
This new line seems an unnecessary change, please undo.
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3847:
URL: https://github.com/apache/calcite/pull/3847#issuecomment-2217951669
@mihaibudiu Hello, I converted the callbinding after parameter verification, which only applies to the map function of spark.
I debugged the spark source code and found that the type has been converted before entering the logical plan.
What do you think
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3847:
URL: https://github.com/apache/calcite/pull/3847#discussion_r1672687245
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8182,6 +8182,19 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) {
"CHAR(3) NOT NULL ARRAY NOT NULL");
f1.checkScalar("map_keys(map('foo', 1, null, 2))", "[foo, null]",
"CHAR(3) ARRAY NOT NULL");
+
+ f1.checkScalar("map_keys(map('foo', 1, null, 2))", "[foo, null]",
Review Comment:
I am assuming these have been checked against spark.
Perhaps you can add a comment, also listing the spark version - Spark has been known to change function behaviors in the past.
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -1491,6 +1496,43 @@ private static class PeriodOperandTypeChecker
}
}
+ /**
+ * Parameter type-checking strategy where types must be Map
+ * and adjust their types to suit the Map function's constructor.
+ */
+ private static class MapSparkFunctionOperandTypeChecker extends SameOperandTypeChecker {
+ MapSparkFunctionOperandTypeChecker() {
+ super(1);
+ }
+
+ @Override public boolean checkOperandTypes(
+ SqlCallBinding callBinding,
+ boolean throwOnFailure) {
+
+ final SqlNode op0 = callBinding.operand(0);
+ if (!OperandTypes.MAP.checkSingleOperandType(
+ callBinding,
+ op0,
+ 0,
+ throwOnFailure)) {
+ return false;
+ }
+
+ final RelDataType mapKeyType =
+ getKeyTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+ final RelDataType mapValueType =
+ getValueTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+
+ // If the key and value types are not unknown,
+ // adjust their types to suit the Map function's constructor.
+ if (mapKeyType.getSqlTypeName() != SqlTypeName.UNKNOWN
Review Comment:
I think we have discussed this in the past: I don't think that the type checker is supposed to modify the node that is being checked.
There are type checking strategies that will backtrack (e.g., SqlOperandTypeChecker.or), and they do not expect the checked data structure to change.
I think this pattern is very dangerous, and can lead to hard to diagnose bugs.
On the other hand, I don't know how this should be done properly. The map function does need to introduce type casts. But maybe the typechecking stage is not the right stage.
##########
core/src/main/java/org/apache/calcite/sql/type/NonNullableAccessors.java:
##########
@@ -58,4 +58,10 @@ public static RelDataType getKeyTypeOrThrow(RelDataType type) {
return requireNonNull(type.getKeyType(),
() -> "keyType is null for " + type);
}
+
+ @API(since = "1.37", status = API.Status.EXPERIMENTAL)
Review Comment:
Is this annotation 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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3847:
URL: https://github.com/apache/calcite/pull/3847#issuecomment-2211775223
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3847) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3847&resolved=false&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3847&resolutions=WONTFIX)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3847&resolved=false&sinceLeakPeriod=true)
 [89.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3847&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3847&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3847)
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai closed pull request #3847: [CALCITE-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType
URL: https://github.com/apache/calcite/pull/3847
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3847:
URL: https://github.com/apache/calcite/pull/3847#discussion_r1676829780
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -1491,6 +1496,43 @@ private static class PeriodOperandTypeChecker
}
}
+ /**
+ * Parameter type-checking strategy where types must be Map
+ * and adjust their types to suit the Map function's constructor.
+ */
+ private static class MapSparkFunctionOperandTypeChecker extends SameOperandTypeChecker {
+ MapSparkFunctionOperandTypeChecker() {
+ super(1);
+ }
+
+ @Override public boolean checkOperandTypes(
+ SqlCallBinding callBinding,
+ boolean throwOnFailure) {
+
+ final SqlNode op0 = callBinding.operand(0);
+ if (!OperandTypes.MAP.checkSingleOperandType(
+ callBinding,
+ op0,
+ 0,
+ throwOnFailure)) {
+ return false;
+ }
+
+ final RelDataType mapKeyType =
+ getKeyTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+ final RelDataType mapValueType =
+ getValueTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+
+ // If the key and value types are not unknown,
+ // adjust their types to suit the Map function's constructor.
+ if (mapKeyType.getSqlTypeName() != SqlTypeName.UNKNOWN
Review Comment:
Currently, this type check is specially prepared for Spark's map function, but there may be some problems that are difficult to eliminate as you said. However, Spark currently performs some type conversions during parameter checking. I have to admit that Spark does not do this very well.
I believe that after I have a deeper understanding of Calcite and the type system in the future, I can improve this part. I hope that day will not be too far away.
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3847:
URL: https://github.com/apache/calcite/pull/3847#issuecomment-2226926775
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3847) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3847&resolved=false&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3847&resolutions=WONTFIX)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3847&resolved=false&sinceLeakPeriod=true)
 [89.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3847&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3847&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3847)
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3847:
URL: https://github.com/apache/calcite/pull/3847#discussion_r1676991726
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -1491,6 +1496,43 @@ private static class PeriodOperandTypeChecker
}
}
+ /**
+ * Parameter type-checking strategy where types must be Map
+ * and adjust their types to suit the Map function's constructor.
+ */
+ private static class MapSparkFunctionOperandTypeChecker extends SameOperandTypeChecker {
+ MapSparkFunctionOperandTypeChecker() {
+ super(1);
+ }
+
+ @Override public boolean checkOperandTypes(
+ SqlCallBinding callBinding,
+ boolean throwOnFailure) {
+
+ final SqlNode op0 = callBinding.operand(0);
+ if (!OperandTypes.MAP.checkSingleOperandType(
+ callBinding,
+ op0,
+ 0,
+ throwOnFailure)) {
+ return false;
+ }
+
+ final RelDataType mapKeyType =
+ getKeyTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+ final RelDataType mapValueType =
+ getValueTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+
+ // If the key and value types are not unknown,
+ // adjust their types to suit the Map function's constructor.
+ if (mapKeyType.getSqlTypeName() != SqlTypeName.UNKNOWN
Review Comment:
ok, thank you.
done
--
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-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3847:
URL: https://github.com/apache/calcite/pull/3847#discussion_r1676991726
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -1491,6 +1496,43 @@ private static class PeriodOperandTypeChecker
}
}
+ /**
+ * Parameter type-checking strategy where types must be Map
+ * and adjust their types to suit the Map function's constructor.
+ */
+ private static class MapSparkFunctionOperandTypeChecker extends SameOperandTypeChecker {
+ MapSparkFunctionOperandTypeChecker() {
+ super(1);
+ }
+
+ @Override public boolean checkOperandTypes(
+ SqlCallBinding callBinding,
+ boolean throwOnFailure) {
+
+ final SqlNode op0 = callBinding.operand(0);
+ if (!OperandTypes.MAP.checkSingleOperandType(
+ callBinding,
+ op0,
+ 0,
+ throwOnFailure)) {
+ return false;
+ }
+
+ final RelDataType mapKeyType =
+ getKeyTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+ final RelDataType mapValueType =
+ getValueTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+
+ // If the key and value types are not unknown,
+ // adjust their types to suit the Map function's constructor.
+ if (mapKeyType.getSqlTypeName() != SqlTypeName.UNKNOWN
Review Comment:
ok, thank you.
--
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