You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "gianm (via GitHub)" <gi...@apache.org> on 2023/06/30 21:17:56 UTC

[GitHub] [calcite] gianm commented on a diff in pull request #3211: [CALCITE-5708] Change SUBSTRING result if either of parameters is NULL

gianm commented on code in PR #3211:
URL: https://github.com/apache/calcite/pull/3211#discussion_r1248287945


##########
core/src/test/resources/sql/functions.iq:
##########
@@ -938,5 +938,19 @@ table(AUX.TBLFUN_IDENTITY(3)) as t3(v);
 
 !ok
 
+# SUBSTRING

Review Comment:
   I suggest including a test for the 2-arg form too. Like:
   
   ```
   select SUBSTRING('text' FROM NULL)
   ```
   
   It should return null.



##########
core/src/main/java/org/apache/calcite/sql/type/SqlTypeFamily.java:
##########
@@ -244,7 +244,7 @@ public Collection<SqlTypeName> getTypeNames() {
     case EXACT_NUMERIC:
       return SqlTypeUtil.getMaxPrecisionScaleDecimal(factory);
     case INTEGER:
-      return factory.createSqlType(SqlTypeName.BIGINT);
+      return factory.createSqlType(SqlTypeName.INTEGER);

Review Comment:
   Why this change? I would think that `BIGINT` is a good default concrete type for the family `INTEGER`, since it's the least restrictive in the family. Seems like this may have unwanted effects, if it causes inference for the `INTEGER` family to use a too-narrow type.



##########
core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java:
##########
@@ -1040,6 +1040,11 @@ void testDyadicCollateOperator() {
         .columnType("VARCHAR(1) NOT NULL");
     expr("substring('a', 1, '3')")
         .columnType("VARCHAR(1) NOT NULL");
+
+    // Correctly processed null string and params.

Review Comment:
   I suggest including a test for the 2-arg form too. Like:
   
   ```
   expr("SUBSTRING('text' FROM NULL)").ok();
   ```



-- 
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