You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/12/29 13:55:46 UTC

[GitHub] [ignite] alex-plekhanov commented on a diff in pull request #10464: IGNITE-18458 Fixed NPE on DML on non-existed table

alex-plekhanov commented on code in PR #10464:
URL: https://github.com/apache/ignite/pull/10464#discussion_r1058965837


##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java:
##########
@@ -458,6 +458,45 @@ public void testMergeKeysConflict() {
             "Failed to MERGE some keys due to keys conflict");
     }
 
+    /**
+     * Ensure that DML operations fails with proper errors on non-existent table
+     */
+    @Test
+    public void testFailureOnNonExistentTable() {
+        assertThrows("INSERT INTO NON_EXISTENT_TABLE(ID, NAME) VALUES (1, 'Name')",
+            IgniteSQLException.class,
+            "Failed to validate query. From line 1, column 13 to line 1, column 30: " +

Review Comment:
   Let's just check substring `"Object 'NON_EXISTENT_TABLE' not found"`, not full message (checking position looking weird, at least for UPDATE statement with column 1-55)



##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/PrepareServiceImpl.java:
##########
@@ -102,9 +102,14 @@ public PrepareServiceImpl(GridKernalContext ctx) {
                         "querySql=\"" + ctx.query() + "\"]", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
             }
         }
-        catch (ValidationException | CalciteContextException e) {
+        catch (CalciteContextException e) {
             throw new IgniteSQLException("Failed to validate query. " + e.getMessage(), IgniteQueryErrorCode.PARSING, e);
         }
+        catch (ValidationException e) {
+            String cause = e.getCause() == null ? e.getMessage() : e.getCause().getMessage();
+
+            throw new IgniteSQLException("Failed to validate query. " + cause, IgniteQueryErrorCode.PARSING, e);
+        }

Review Comment:
   Let's change `IgnitePlanner.validate()` instead (construct `ValidationException` with the correct message).



-- 
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: notifications-unsubscribe@ignite.apache.org

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