This is an automated email from the ASF dual-hosted git repository.

xuzifu666 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 0ce0c5ae2f Test case for [CALCITE-5161] NPE when inserting a null 
value into a decimal column
0ce0c5ae2f is described below

commit 0ce0c5ae2f7055f13551ebcde8e1aaa2ff17b469
Author: Yu Xu <[email protected]>
AuthorDate: Mon Apr 13 14:55:17 2026 +0800

    Test case for [CALCITE-5161] NPE when inserting a null value into a decimal 
column
---
 .../org/apache/calcite/test/JdbcAdapterTest.java   | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java 
b/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java
index 8d8d66371c..df12fbe8a8 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java
@@ -80,6 +80,35 @@ class JdbcAdapterTest {
         .returnsCount(14);
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-5161";>[CALCITE-5161]
+   * NPE when inserting a null value into a decimal column</a>. */
+  @Test void testInsertNull() {
+    // Insert data with null values
+    CalciteAssert.model(FoodmartSchema.FOODMART_MODEL)
+        .query("insert into \"foodmart\".\"promotion\" "
+            + "values (9999, 111, 'Test', NULL, NULL, NULL, NULL)")
+        .updates(1);
+
+    // Verify data was inserted
+    CalciteAssert.model(FoodmartSchema.FOODMART_MODEL)
+        .query("select \"promotion_id\", \"promotion_district_id\", 
\"promotion_name\", "
+            + "\"media_type\", \"cost\", \"start_date\", \"end_date\" "
+            + "from \"foodmart\".\"promotion\" where \"promotion_id\" = 9999")
+        .returns("promotion_id=9999; promotion_district_id=111; 
promotion_name=Test; "
+            + "media_type=null; cost=null; start_date=null; end_date=null\n");
+
+    // Delete the inserted data
+    CalciteAssert.model(FoodmartSchema.FOODMART_MODEL)
+        .query("delete from \"foodmart\".\"promotion\" where \"promotion_id\" 
= 9999")
+        .updates(1);
+
+    // Verify data was deleted
+    CalciteAssert.model(FoodmartSchema.FOODMART_MODEL)
+        .query("select count(*) as c from \"foodmart\".\"promotion\" where 
\"promotion_id\" = 9999")
+        .returns("C=0\n");
+  }
+
   /** Test case for
    * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6462";>[CALCITE-6462]
    * VolcanoPlanner internal valid may throw exception when log trace is 
enabled</a>. */

Reply via email to