You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2025/08/15 17:50:07 UTC

(asterixdb) 04/17: [NO ISSUE][COMP] Remove check-unknown for Insert/Upsert on datasets with meta part

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

mblow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit de368f5257393693f773859918c36b8090f16510
Author: Peeyush Gupta <pe...@couchbase.com>
AuthorDate: Tue Jul 1 17:13:35 2025 -0700

    [NO ISSUE][COMP] Remove check-unknown for Insert/Upsert on datasets with meta part
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Ext-ref: MB-67221
    Change-Id: I55766c9a334f40efd996e2b453f7237aec739966
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20010
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Ali Alsuliman <al...@gmail.com>
---
 .../optimizer/rules/IntroduceDynamicTypeCastRule.java        | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java
index a9ad7cecd1..7121bc0ba5 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java
@@ -27,6 +27,7 @@ import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.lang.common.util.FunctionUtil;
 import org.apache.asterix.metadata.declared.DataSource;
+import org.apache.asterix.metadata.declared.DatasetDataSource;
 import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
 import org.apache.asterix.om.types.ARecordType;
@@ -165,6 +166,11 @@ public class IntroduceDynamicTypeCastRule implements IAlgebraicRewriteRule {
             inputRecordType = ((AUnionType) inputRecordType).getActualType();
             checkUnknown = true;
         }
+        boolean hasMetaPart = op.getOperatorTag() == LogicalOperatorTag.INSERT_DELETE_UPSERT
+                && ((DatasetDataSource) ((InsertDeleteUpsertOperator) op).getDataSource()).getDataset().hasMetaPart();
+        if (hasMetaPart) {
+            checkUnknown = false;
+        }
 
         /** see whether the input record type needs to be casted */
         boolean cast = !compatible(requiredRecordType, inputRecordType, op);
@@ -173,7 +179,11 @@ public class IntroduceDynamicTypeCastRule implements IAlgebraicRewriteRule {
             recordVar = addWrapperFunction(requiredRecordType, recordVar, op, context, BuiltinFunctions.CHECK_UNKNOWN);
         }
         if (cast) {
-            addWrapperFunction(requiredRecordType, recordVar, op, context, BuiltinFunctions.CAST_TYPE);
+            if (hasMetaPart) {
+                addWrapperFunction(requiredRecordType, recordVar, op, context, BuiltinFunctions.CAST_TYPE_LAX);
+            } else {
+                addWrapperFunction(requiredRecordType, recordVar, op, context, BuiltinFunctions.CAST_TYPE);
+            }
         }
         return cast || checkUnknown;
     }