vlsi commented on a change in pull request #2312:
URL: https://github.com/apache/calcite/pull/2312#discussion_r551894513



##########
File path: core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
##########
@@ -93,6 +95,29 @@ public SqlCastFunction() {
 
   //~ Methods ----------------------------------------------------------------
 
+  @Override public void validateCall(final SqlCall call, final SqlValidator 
validator,
+      final SqlValidatorScope scope,
+      final SqlValidatorScope operandScope) {
+    try {
+      super.validateCall(call, validator, scope, operandScope);
+    } catch (UnsupportedOperationException ex) {
+      assert call.operandCount() == 2;
+      throw validator.newValidationError(call,
+          RESOURCE.cannotCastToType(call.operand(1).toString()));
+    }
+  }
+
+  @Override public RelDataType deriveType(final SqlValidator validator,
+      final SqlValidatorScope scope, final SqlCall call) {
+    try {
+      return super.deriveType(validator, scope, call);
+    } catch (UnsupportedOperationException ex) {
+      assert call.operandCount() == 2;

Review comment:
       Could you please remove the assert from here?
   What is the purpose of the assert?

##########
File path: core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
##########
@@ -93,6 +95,29 @@ public SqlCastFunction() {
 
   //~ Methods ----------------------------------------------------------------
 
+  @Override public void validateCall(final SqlCall call, final SqlValidator 
validator,
+      final SqlValidatorScope scope,
+      final SqlValidatorScope operandScope) {
+    try {
+      super.validateCall(call, validator, scope, operandScope);
+    } catch (UnsupportedOperationException ex) {
+      assert call.operandCount() == 2;

Review comment:
       Could you please remove the assert from here?
   What is the purpose of the assert?

##########
File path: core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
##########
@@ -93,6 +95,29 @@ public SqlCastFunction() {
 
   //~ Methods ----------------------------------------------------------------
 
+  @Override public void validateCall(final SqlCall call, final SqlValidator 
validator,
+      final SqlValidatorScope scope,
+      final SqlValidatorScope operandScope) {
+    try {
+      super.validateCall(call, validator, scope, operandScope);
+    } catch (UnsupportedOperationException ex) {
+      assert call.operandCount() == 2;
+      throw validator.newValidationError(call,
+          RESOURCE.cannotCastToType(call.operand(1).toString()));

Review comment:
       Should the original `UnsupportedOperationException` be kept as a `cause` 
of the exception?

##########
File path: core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
##########
@@ -93,6 +95,29 @@ public SqlCastFunction() {
 
   //~ Methods ----------------------------------------------------------------
 
+  @Override public void validateCall(final SqlCall call, final SqlValidator 
validator,
+      final SqlValidatorScope scope,
+      final SqlValidatorScope operandScope) {
+    try {
+      super.validateCall(call, validator, scope, operandScope);
+    } catch (UnsupportedOperationException ex) {
+      assert call.operandCount() == 2;
+      throw validator.newValidationError(call,
+          RESOURCE.cannotCastToType(call.operand(1).toString()));
+    }
+  }
+
+  @Override public RelDataType deriveType(final SqlValidator validator,
+      final SqlValidatorScope scope, final SqlCall call) {
+    try {
+      return super.deriveType(validator, scope, call);
+    } catch (UnsupportedOperationException ex) {
+      assert call.operandCount() == 2;
+      throw validator.newValidationError(call,
+          RESOURCE.cannotCastToType(call.operand(1).toString()));

Review comment:
       Should the original `UnsupportedOperationException` be kept as a `cause` 
of the exception?




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to