You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/04/11 14:50:04 UTC

[GitHub] [flink] matriv opened a new pull request, #19426: [FLINK-25928] Throw validation error early for CAST

matriv opened a new pull request, #19426:
URL: https://github.com/apache/flink/pull/19426

   ## What is the purpose of the change
   
   Throw early a validation error with workaround suggestion for
   casting between numeric types and `TIMESTAMP`/`TIMESTAMP_LTZ` before
   reaching the `CastRuleProvider`. This way we don't need to implement
   such errors in Cast Rules and we can throw the error message early
   before reaching the code generator.
   
   
   ## Brief change log
   
     - Implement validation for from/to `CAST` pairs in `LogicalTypeCasts`
     - Remove the Numeric <-> Timestamp/Timestamp_ltz rules which were added only to throw this message
   
   
   ## Verifying this change
   
   This change is already covered by existing tests, such as `CastFunctionITCase`, `TemporalTypesTest`.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): **no**
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: **no**
     - The serializers: **no**
     - The runtime per-record code paths (performance sensitive): **no**
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: **no**
     - The S3 file system connector: **no**
   
   ## Documentation
   
     - Does this pull request introduce a new feature? **no**
     - If yes, how is the feature documented? **not applicable**
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] matriv commented on a diff in pull request #19426: [FLINK-25928][table-planner] Throw validation error early for CAST

Posted by GitBox <gi...@apache.org>.
matriv commented on code in PR #19426:
URL: https://github.com/apache/flink/pull/19426#discussion_r848115742


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/utils/LogicalTypeCasts.java:
##########
@@ -589,6 +591,37 @@ protected Boolean defaultMethod(LogicalType targetType) {
         }
     }
 
+    /**
+     * Check if the source/target pair is not allowed and throw a {@link ValidationException} with a
+     * useful error message.
+     */

Review Comment:
   We need a call to some method that does this validation before:
   ```
   return SqlTypeUtil.canCastFrom(toType, fromType, true);
   ```
   So we have to do it in a separate method, I don't see another way, but the `supportsExplicitCast` will call it as it is in this PR already, so for our Flink stack, there is no need for a separate method call.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] matriv commented on a diff in pull request #19426: [FLINK-25928][table-planner] Throw validation error early for CAST

Posted by GitBox <gi...@apache.org>.
matriv commented on code in PR #19426:
URL: https://github.com/apache/flink/pull/19426#discussion_r848115742


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/utils/LogicalTypeCasts.java:
##########
@@ -589,6 +591,37 @@ protected Boolean defaultMethod(LogicalType targetType) {
         }
     }
 
+    /**
+     * Check if the source/target pair is not allowed and throw a {@link ValidationException} with a
+     * useful error message.
+     */

Review Comment:
   We need a call to some method that does this validation before:
   ```return SqlTypeUtil.canCastFrom(toType, fromType, true);
   ```
   So we have to do it in a separate method, I don't see another way, but the `supportsExplicitCast` will call it as it is in this PR already, so for our Flink stack, there is no need for a separate method call.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] flinkbot commented on pull request #19426: [FLINK-25928] Throw validation error early for CAST

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #19426:
URL: https://github.com/apache/flink/pull/19426#issuecomment-1095157121

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "1dd50a02ec38485aa442a46ca439df7861565ed0",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "1dd50a02ec38485aa442a46ca439df7861565ed0",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 1dd50a02ec38485aa442a46ca439df7861565ed0 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] matriv commented on pull request #19426: [FLINK-25928] Throw validation error early for CAST

Posted by GitBox <gi...@apache.org>.
matriv commented on PR #19426:
URL: https://github.com/apache/flink/pull/19426#issuecomment-1095153446

   Added the validation only in the `supportsExplicitCasting` as there are cases where we do implicit casting between TIMESTAMP and numeric, i.e. In `TemporalTypesTest`: 
   ```
       testAllApis(
         'f2 + 10.days + 4.millis,
         "f2 + INTERVAL '10 00:00:00.004' DAY TO SECOND",
         "1990-10-24 10:20:45.127")
   ```


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] slinkydeveloper commented on a diff in pull request #19426: [FLINK-25928] Throw validation error early for CAST

Posted by GitBox <gi...@apache.org>.
slinkydeveloper commented on code in PR #19426:
URL: https://github.com/apache/flink/pull/19426#discussion_r847453122


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/utils/LogicalTypeCasts.java:
##########
@@ -589,6 +591,37 @@ protected Boolean defaultMethod(LogicalType targetType) {
         }
     }
 
+    /**
+     * Check if the source/target pair is not allowed and throw a {@link ValidationException} with a
+     * useful error message.
+     */

Review Comment:
   This javadoc is not true, as if the source target pair is not allowed in all other cases except numeric to timestamp, this function won't fail.
   
   In general I don't like much the fact that we have both `validate` and `supportsExplicitCast`, is there a better way to solve this?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org