You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "chucheng92 (via GitHub)" <gi...@apache.org> on 2023/07/20 08:19:58 UTC
[GitHub] [calcite] chucheng92 commented on a diff in pull request #3324: [CALCITE-5862] Incorrect spark semantics of array function when elements have Numeric and Character types
chucheng92 commented on code in PR #3324:
URL: https://github.com/apache/calcite/pull/3324#discussion_r1269113990
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -955,10 +955,38 @@ static RelDataType deriveTypeSplit(SqlOperatorBinding operatorBinding,
.withKind(SqlKind.CONCAT_WS_MSSQL);
private static RelDataType arrayReturnType(SqlOperatorBinding opBinding) {
- RelDataType type =
- opBinding.getOperandCount() > 0
- ? ReturnTypes.LEAST_RESTRICTIVE.inferReturnType(opBinding)
- : opBinding.getTypeFactory().createUnknownType();
+ // only numeric & character types check
+ List<RelDataType> numericTypes = new ArrayList<>();
+ List<RelDataType> characterTypes = new ArrayList<>();
+ List<RelDataType> nullTypes = new ArrayList<>();
+ for (int i = 0; i < opBinding.getOperandCount(); i++) {
+ SqlTypeFamily family = opBinding.getOperandType(i).getSqlTypeName().getFamily();
+ if (family == SqlTypeFamily.NUMERIC) {
+ numericTypes.add(opBinding.getOperandType(i));
+ } else if (family == SqlTypeFamily.CHARACTER) {
+ characterTypes.add(opBinding.getOperandType(i));
+ } else if (family == SqlTypeFamily.NULL) {
+ nullTypes.add(opBinding.getOperandType(i));
+ } else {
+ break;
+ }
+ }
+
+ boolean onlyNumericCharacterTypes = opBinding.getOperandCount() > 0
Review Comment:
good point. I have fixed this. PTAL.
--
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