>From Shahrzad Shirazi <[email protected]>: Shahrzad Shirazi has uploaded this change for review. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21146?usp=email )
Change subject: WIP:Fix nested UPDATE on arrays to handle non-record element replacement ...................................................................... WIP:Fix nested UPDATE on arrays to handle non-record element replacement Change-Id: I72c9aa078a93c4a4eecc35ac65d0d65137f48fdb --- A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.24.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.25.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.26.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/results/update-statements/simple-case/simple-case.25.adm A asterixdb/asterix-app/src/test/resources/runtimets/results/update-statements/simple-case/simple-case.26.adm M asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeEvaluator.java M asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordTransformDescriptor.java 7 files changed, 126 insertions(+), 7 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/46/21146/1 diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.24.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.24.ddl.sqlpp new file mode 100644 index 0000000..4825054 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.24.ddl.sqlpp @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +Use test; + +CREATE TYPE UserType2 AS { + userId: int, + email: string, + username: string, + isActive: boolean +}; + +CREATE DATASET UserTypes2(UserType2) +PRIMARY KEY userId; + +INSERT INTO UserTypes2([ + { + "userId": 3, + "email": "[email protected]", + "username": "carol", + "isActive": true, + "roles": [ + { "roleId": "role1", "roleName": "moderator" }, + { "roleId": "role2", "roleName": "reviewer" }, + { "roleId": "role3", "roleName": "reviewer" }, + { "roleId": "role4", "roleName": "reviewer" } + ] + } +]); + + + + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.25.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.25.query.sqlpp new file mode 100644 index 0000000..26189af --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.25.query.sqlpp @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +Use test; + +UPDATE UserTypes2 AS u +(update u.roles as p at o +set p="pp" +where o=2 ) +WHERE u.userId= 3 +returning u; + + + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.26.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.26.query.sqlpp new file mode 100644 index 0000000..2f65d9d --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/update-statements/simple-case/simple-case.26.query.sqlpp @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +Use test; + +UPDATE UserTypes2 AS u +(update u.roles as p at o +set p=5) +WHERE u.userId= 3 +returning u; + + + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/update-statements/simple-case/simple-case.25.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/update-statements/simple-case/simple-case.25.adm new file mode 100644 index 0000000..cd1aec1 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/update-statements/simple-case/simple-case.25.adm @@ -0,0 +1 @@ +{ "userId": 3, "email": "[email protected]", "username": "carol", "isActive": true, "roles": [ { "roleId": "role1", "roleName": "moderator" }, "pp", { "roleId": "role3", "roleName": "reviewer" }, { "roleId": "role4", "roleName": "reviewer" } ] } diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/update-statements/simple-case/simple-case.26.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/update-statements/simple-case/simple-case.26.adm new file mode 100644 index 0000000..52bf88c --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/update-statements/simple-case/simple-case.26.adm @@ -0,0 +1 @@ +{ "userId": 3, "email": "[email protected]", "username": "carol", "isActive": true, "roles": [ 5, 5, 5, 5 ] } diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeEvaluator.java index adbf310..b01fc3c 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeEvaluator.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeEvaluator.java @@ -30,6 +30,7 @@ import org.apache.asterix.om.pointables.PointableAllocator; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; import org.apache.asterix.om.pointables.base.IVisitablePointable; +import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils; import org.apache.asterix.om.types.ARecordType; import org.apache.asterix.om.types.ATypeTag; import org.apache.asterix.om.types.IAType; @@ -96,9 +97,15 @@ eval0 = args[0].createScalarEvaluator(ctx); eval1 = args[1].createScalarEvaluator(ctx); - outRecType = (ARecordType) argTypes[0]; - ARecordType inRecType0 = (ARecordType) argTypes[1]; - ARecordType inRecType1 = (ARecordType) argTypes[2]; + outRecType = argTypes[0] != null ? TypeComputeUtils.extractRecordType(argTypes[0]) : null; + ARecordType inRecType0 = TypeComputeUtils.extractRecordType(argTypes[1]); + if (inRecType0 == null) { + inRecType0 = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE; + } + ARecordType inRecType1 = TypeComputeUtils.extractRecordType(argTypes[2]); + if (inRecType1 == null) { + inRecType1 = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE; + } PointableAllocator pa = new PointableAllocator(); vp0 = pa.allocateRecordValue(inRecType0); diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordTransformDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordTransformDescriptor.java index 26ee2d0..77016d2 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordTransformDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordTransformDescriptor.java @@ -23,7 +23,6 @@ import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; import org.apache.asterix.om.functions.IFunctionTypeInferer; -import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils; import org.apache.asterix.om.types.IAType; import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; import org.apache.asterix.runtime.functions.FunctionTypeInferers; @@ -71,9 +70,10 @@ @Override public void setImmutableStates(Object... states) { - argTypes[0] = TypeComputeUtils.extractRecordType((IAType) states[0]); - argTypes[1] = TypeComputeUtils.extractRecordType((IAType) states[1]); - argTypes[2] = TypeComputeUtils.extractRecordType((IAType) states[2]); + argTypes[0] = (IAType) states[0]; + argTypes[1] = (IAType) states[1]; + argTypes[2] = (IAType) states[2]; + } @Override -- To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21146?usp=email To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: asterixdb Gerrit-Branch: lumina Gerrit-Change-Id: I72c9aa078a93c4a4eecc35ac65d0d65137f48fdb Gerrit-Change-Number: 21146 Gerrit-PatchSet: 1 Gerrit-Owner: Shahrzad Shirazi <[email protected]>
