Yingyi Bu has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/1401
Change subject: ASTERIXDB-1755: add UPSERT in SQL++. ...................................................................... ASTERIXDB-1755: add UPSERT in SQL++. Change-Id: I02b2be7ff2653573eccb48037895f5c8c4bc8c74 --- A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.3.server.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.4.sleep.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.5.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.6.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.7.server.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.8.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.4.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.3.query.sqlpp M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj 44 files changed, 1,483 insertions(+), 0 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/01/1401/1 diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.1.ddl.sqlpp new file mode 100644 index 0000000..d426687 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.1.ddl.sqlpp @@ -0,0 +1,46 @@ +/* + * 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. + */ +/* + * Description : Create a feed with upsert option. Push record twice + * with minor changes. The updated record will not cause duplicate + * key exception and the data will be updated. + * Expected Res : Success + * Date : 13th Aug 2016 + */ +drop dataverse experiments if exists; +create dataverse experiments; +use experiments; + +create type TwitterUser if not exists as open{ + `screen-name`: string, + friends_count: int32, + name: string, + followers_count: int32 +}; + +create dataset TwitterUsers(TwitterUser) primary key `screen-name`; + +create feed UserFeed using socket_adapter +( + ("sockets"="127.0.0.1:10001"), + ("address-type"="IP"), + ("type-name"="TwitterUser"), + ("format"="adm"), + ("upsert-feed"="true") +); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.2.update.sqlpp new file mode 100644 index 0000000..32d8389 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.2.update.sqlpp @@ -0,0 +1,29 @@ +/* + * 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. + */ +/* + * Description : Create a feed with upsert option. Push record twice + * with minor changes. The updated record will not cause duplicate + * key exception and the data will be updated. + * Expected Res : Success + * Date : 13th Aug 2016 + */ +use experiments; +set `wait-for-completion-feed` "false"; + +connect feed UserFeed to dataset TwitterUsers; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.3.server.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.3.server.sqlpp new file mode 100644 index 0000000..3da77f7 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.3.server.sqlpp @@ -0,0 +1,26 @@ +/* + * 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. + */ +/* + * Description : Create a feed with upsert option. Push record twice + * with minor changes. The updated record will not cause duplicate + * key exception and the data will be updated. + * Expected Res : Success + * Date : 13th Aug 2016 + */ +start client 10001 file-client localhost ../asterix-app/data/tinysocial/twu_update.adm 500 50 1000 \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.4.sleep.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.4.sleep.sqlpp new file mode 100644 index 0000000..99ad0d7 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.4.sleep.sqlpp @@ -0,0 +1,26 @@ +/* + * 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. + */ +/* + * Description : Create a feed with upsert option. Push record twice + * with minor changes. The updated record will not cause duplicate + * key exception and the data will be updated. + * Expected Res : Success + * Date : 13th Aug 2016 + */ +10000 \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.5.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.5.update.sqlpp new file mode 100644 index 0000000..8e2dff8 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.5.update.sqlpp @@ -0,0 +1,28 @@ +/* + * 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. + */ +/* + * Description : Create a feed with upsert option. Push record twice + * with minor changes. The updated record will not cause duplicate + * key exception and the data will be updated. + * Expected Res : Success + * Date : 13th Aug 2016 + */ + +use experiments; +disconnect feed UserFeed from dataset TwitterUsers; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.6.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.6.query.sqlpp new file mode 100644 index 0000000..77ee294 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.6.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. + */ +/* + * Description : Create a feed with upsert option. Push record twice + * with minor changes. The updated record will not cause duplicate + * key exception and the data will be updated. + * Expected Res : Success + * Date : 13th Aug 2016 + */ + +use experiments; + +select value x +from TwitterUsers x +order by x.`screen-name`; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.7.server.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.7.server.sqlpp new file mode 100644 index 0000000..d331474 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.7.server.sqlpp @@ -0,0 +1,27 @@ +/* + * 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. + */ +/* + * Description : Create a feed with upsert option. Push record twice + * with minor changes. The updated record will not cause duplicate + * key exception and the data will be updated. + * Expected Res : Success + * Date : 13th Aug 2016 + */ + +stop 10001 \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.8.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.8.ddl.sqlpp new file mode 100644 index 0000000..8ba3fcd --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/upsert-feed/upsert-feed.8.ddl.sqlpp @@ -0,0 +1,27 @@ +/* + * 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. + */ +/* + * Description : Create a feed with upsert option. Push record twice + * with minor changes. The updated record will not cause duplicate + * key exception and the data will be updated. + * Expected Res : Success + * Date : 13th Aug 2016 + */ +use experiments; +drop dataverse experiments; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.1.ddl.sqlpp new file mode 100644 index 0000000..751ba27 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.1.ddl.sqlpp @@ -0,0 +1,46 @@ +/* + * 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. + */ +/* + * Description : Test filters with upsert pipeline + * Expected Res : Success + * Date : 13th Jan 2016 + */ + +drop dataverse test if exists; +create dataverse test; + +use test; + +create type FacebookMessageType as closed { + `message-id`: int64, + `author-id`: int64, + `in-response-to`: int64?, + `sender-location`: point?, + message: string, + `send-time`: datetime +} + +create dataset FacebookMessages(FacebookMessageType) +primary key `message-id`; + +create dataset FilteredFacebookMessages(FacebookMessageType) +primary key `message-id` with filter on `send-time`; + +create index AutherIdx on FilteredFacebookMessages(`author-id`); +create index MessageIdx on FilteredFacebookMessages(message); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.2.update.sqlpp new file mode 100644 index 0000000..008c03c --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.2.update.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; + +load dataset FilteredFacebookMessages using localfs +(("path"="asterix_nc1://data/fbm-with-send-time.adm"),("format"="adm")); + +load dataset FacebookMessages using localfs +(("path"="asterix_nc1://data/more-fbm-with-send-time.adm"),("format"="adm")); + +upsert into FilteredFacebookMessages( + FROM FacebookMessages AS x + SELECT VALUE x +); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.3.query.sqlpp new file mode 100644 index 0000000..08b9d51 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/filtered-dataset/filtered-dataset.3.query.sqlpp @@ -0,0 +1,24 @@ +/* + * 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; + +FROM FilteredFacebookMessages m +WHERE m.`send-time` > datetime("2012-08-20T10:10:00") +SELECT VALUE m; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.1.ddl.sqlpp new file mode 100644 index 0000000..1eaeba3 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.1.ddl.sqlpp @@ -0,0 +1,38 @@ +/* + * 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. + */ +/* + * Description : Upsert into a dataset which has a foreign datatype + * Expected Res : Success + * Date : Aug 18th 2016 + */ + +drop dataverse b if exists; +drop dataverse a if exists; +create dataverse a; +create dataverse b; +use a; + +create type TypeA as closed{ +id:int32, +age:int32 +}; + +use b; + +create dataset UpsertTo(a.TypeA) primary key id; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.2.update.sqlpp new file mode 100644 index 0000000..588c261 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.2.update.sqlpp @@ -0,0 +1,38 @@ +/* + * 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. + */ +/* + * Description : Upsert into a dataset which has a foreign datatype + * Expected Res : Success + * Date : Aug 18th 2016 + */ + +// upsert UpsertFrom into UpsertTo +use b; + +upsert into UpsertTo( +{"id":1,"age":7} +); + +upsert into UpsertTo( +{"id":2,"age":8} +); + +upsert into UpsertTo( +{"id":1,"age":9} +); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.3.query.sqlpp new file mode 100644 index 0000000..e53f140 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.3.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. + */ +/* + * Description : Upsert into a dataset which has a foreign datatype + * Expected Res : Success + * Date : Aug 18th 2016 + */ + +use b; + +SELECT VALUE x +FROM UpsertTo x +ORDER BY x.id; + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.4.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.4.ddl.sqlpp new file mode 100644 index 0000000..71eaed1 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/issue1587-foreignDataType/issue1587-foreignDataType.4.ddl.sqlpp @@ -0,0 +1,25 @@ +/* + * 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. + */ +/* + * Description : Upsert into a dataset which has a foreign datatype + * Expected Res : Success + * Date : Aug 18th 2016 + */ +drop dataverse b; +drop dataverse a; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.1.ddl.sqlpp new file mode 100644 index 0000000..f9649c7 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.1.ddl.sqlpp @@ -0,0 +1,44 @@ +/* + * 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. + */ +drop dataverse test if exists; +create dataverse test; +use test; + +create type MyRecord as closed { + id: int64, + point: point, + kwds: string, + line1: line, + line2: line, + poly1: polygon, + poly2: polygon, + rec: rectangle, + circle: circle +} + + +create dataset UpsertTo(MyRecord) + primary key id; + + create dataset UpsertFrom(MyRecord) + primary key id; + +create index btree_index on UpsertTo(kwds); +create index rtree_index on UpsertTo(point) type rtree; +create index inverted_index on UpsertTo(kwds) type keyword; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.2.update.sqlpp new file mode 100644 index 0000000..4a316a8 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.2.update.sqlpp @@ -0,0 +1,33 @@ +/* + * 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; + +load dataset UpsertTo +using localfs +(("path"="asterix_nc1://data/spatial/spatialData.json"),("format"="adm")); + +load dataset UpsertFrom +using localfs +(("path"="asterix_nc1://data/spatial/moreSpatialData.json"),("format"="adm")); + + +upsert into UpsertTo( + select value x + from UpsertFrom x +); diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.3.query.sqlpp new file mode 100644 index 0000000..ad45ca2 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-secondaries/multiple-secondaries.3.query.sqlpp @@ -0,0 +1,24 @@ +/* + * 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; + +SELECT o.id id +FROM UpsertTo o +WHERE spatial_intersect(o.point, create_polygon([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0])) +ORDER BY o.id; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.1.ddl.sqlpp new file mode 100644 index 0000000..5d0b5e0 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.1.ddl.sqlpp @@ -0,0 +1,48 @@ +/* + * 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. + */ +drop dataverse test if exists; +create dataverse test; +use test; + +create type OrderTypetmp as closed { + o_orderkey: int64, + o_custkey: int64, + o_orderstatus: string, + o_totalprice: double, + o_orderdate: string, + o_orderpriority: string, + o_clerk: string, + o_shippriority: int64, + o_comment: string +} + +create type OrderType as closed { +nested : OrderTypetmp +} + +create dataset UpsertTo(OrderTypetmp) + primary key o_orderkey; + +create dataset UpsertFrom(OrderTypetmp) + primary key o_orderkey; + + create dataset Orders(OrderType) + primary key nested.o_orderkey; + +create index idx_Orders_Custkey on Orders(nested.o_custkey); diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.2.update.sqlpp new file mode 100644 index 0000000..01a883b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.2.update.sqlpp @@ -0,0 +1,43 @@ +/* + * 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; + +load dataset UpsertTo +using localfs +(("path"="asterix_nc1://data/tpch0.001/orders.tbl"), +("format"="delimited-text"), +("delimiter"="|")) pre-sorted; + +load dataset UpsertFrom +using localfs +(("path"="asterix_nc1://data/tpch0.001/other-orders.tbl"), +("format"="delimited-text"), +("delimiter"="|")) pre-sorted; + +insert into Orders +( + select c as nested + from UpsertTo c +); + +upsert into Orders +( + select c as nested + from UpsertFrom c +); diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.3.query.sqlpp new file mode 100644 index 0000000..03357e5 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nested-index/nested-index.3.query.sqlpp @@ -0,0 +1,24 @@ +/* + * 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; + +select o.nested.o_orderkey, o.nested.o_custkey +from Orders o +where o.nested.o_custkey < 60 +order by o.nested.o_orderkey; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.1.ddl.sqlpp new file mode 100644 index 0000000..6451ed4 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.1.ddl.sqlpp @@ -0,0 +1,41 @@ +/* + * 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. + */ +drop dataverse test if exists; +create dataverse test; +use test; + +create type AddressType as open { + number: int64, + street: string, + city: string +} + +create type CustomerType as open { + cid: int64, + name: string, + age: int64?, + address: AddressType?, + interests: {{string}}, + children: [ { name: string, age: int64? } ] +} + +create dataset Customers(CustomerType) primary key cid; +create dataset MoreCustomers(CustomerType) primary key cid; +create index age_index on Customers(age); + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.2.update.sqlpp new file mode 100644 index 0000000..f3cf58a --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.2.update.sqlpp @@ -0,0 +1,32 @@ +/* + * 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; + +load dataset Customers +using localfs +(("path"="asterix_nc1://data/semistructured/tiny01/customer.adm"),("format"="adm")); + +load dataset MoreCustomers +using localfs +(("path"="asterix_nc1://data/semistructured/tiny01/more-customer.adm"),("format"="adm")); + +upsert into Customers( + from MoreCustomers x + select value x +); diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.3.query.sqlpp new file mode 100644 index 0000000..600faa3 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/nullable-index/nullable-index.3.query.sqlpp @@ -0,0 +1,24 @@ +/* + * 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; + +select value c +from Customers c +where c.age < 20 +order by c.cid; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.1.ddl.sqlpp new file mode 100644 index 0000000..e964d0b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.1.ddl.sqlpp @@ -0,0 +1,56 @@ +/* + * 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. + */ +drop dataverse test if exists; +create dataverse test; +use test; + +create type OrderType as closed { + o_orderkey: int64, + o_custkey: int64, + o_orderstatus: string, + o_totalprice: double, + o_orderdate: string, + o_orderpriority: string, + o_clerk: string, + o_shippriority: int64, + o_comment: string +} + +create type OrderOpenType as open { + o_orderkey: int64, + o_orderstatus: string, + o_totalprice: double, + o_orderdate: string, + o_orderpriority: string, + o_clerk: string, + o_shippriority: int64, + o_comment: string +} + +create dataset Orders(OrderType) + primary key o_orderkey; + + create dataset OtherOrders(OrderType) + primary key o_orderkey; + +create dataset OrdersOpen(OrderOpenType) +primary key o_orderkey; + +create index idx_Orders_Custkey on OrdersOpen(o_custkey:int32?) enforced; + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.2.update.sqlpp new file mode 100644 index 0000000..bebc8d0 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.2.update.sqlpp @@ -0,0 +1,37 @@ +/* + * 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; + +load dataset Orders +using localfs +(("path"="asterix_nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted; + +load dataset OtherOrders +using localfs +(("path"="asterix_nc1://data/tpch0.001/other-orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted; + +insert into OrdersOpen ( + select value x + from OtherOrders x +); + +upsert into OrdersOpen ( + select value x + from Orders x +); diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.3.query.sqlpp new file mode 100644 index 0000000..ce78713 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/open-index/open-index.3.query.sqlpp @@ -0,0 +1,24 @@ +/* + * 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; + +select o.o_orderkey, o.o_custkey +from OrdersOpen o +where o.o_custkey > 40 +order by o.o_orderkey; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.1.ddl.sqlpp new file mode 100644 index 0000000..c970044 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.1.ddl.sqlpp @@ -0,0 +1,37 @@ +/* + * 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. + */ +/* + * Description : Upsert into a dataset which doesn't have any secondary indexes + * Expected Res : Success + * Date : Sep 15th 2015 + */ + +drop dataverse test if exists; +create dataverse test; +use test; + +create type TestType as closed{ +id:int32, +age:int32, +name:string, +salary:double +}; + +create dataset UpsertTo(TestType) primary key id; +create dataset UpsertFrom(TestType) primary key id; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.2.update.sqlpp new file mode 100644 index 0000000..64239cb --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.2.update.sqlpp @@ -0,0 +1,41 @@ +/* + * 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. + */ +/* + * Description : Upsert into a dataset which doesn't have any secondary indexes + * Expected Res : Success + * Date : Sep 15th 2015 + */ + +use test; +// load first dataset +load dataset UpsertTo using +localfs(("format"="delimited-text"), + ("path"="asterix_nc1://data/upsert/raw-data/overlapping.data"), + ("delimiter"=",")); +// load second dataset +load dataset UpsertFrom using +localfs(("format"="delimited-text"), + ("path"="asterix_nc1://data/upsert/raw-data/test-data.txt,asterix_nc1://data/upsert/raw-data/more-data.txt"), + ("delimiter"=",")); + +// upsert UpsertFrom into UpsertTo +upsert into UpsertTo( + from UpsertFrom x + select value x +); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.3.query.sqlpp new file mode 100644 index 0000000..d8a2308 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-index/primary-index.3.query.sqlpp @@ -0,0 +1,28 @@ +/* + * 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. + */ +/* + * Description : Upsert into a dataset which doesn't have any secondary indexes + * Expected Res : Success + * Date : Sep 15th 2015 + */ + +USE test; + +FROM UpsertTo x +SELECT VALUE x; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.1.ddl.sqlpp new file mode 100644 index 0000000..b232d8f --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.1.ddl.sqlpp @@ -0,0 +1,38 @@ +/* + * 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. + */ +/* + * Description : Upsert into a dataset which has a b-tree secondary index + * Expected Res : Success + * Date : Sep 15th 2015 + */ + +drop dataverse test if exists; +create dataverse test; +use test; + +create type TestType as closed{ +id:int32, +age:int32, +name:string, +salary:double +}; + +create dataset UpsertTo(TestType) primary key id; +create index ageindex on UpsertTo(age); +create dataset UpsertFrom(TestType) primary key id; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.2.update.sqlpp new file mode 100644 index 0000000..2f8b334 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.2.update.sqlpp @@ -0,0 +1,41 @@ +/* + * 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. + */ +/* + * Description : Upsert into a dataset which has a b-tree secondary index + * Expected Res : Success + * Date : Sep 15th 2015 + */ + +use test; +// load first dataset +load dataset UpsertTo using +localfs(("format"="delimited-text"), + ("path"="asterix_nc1://data/upsert/raw-data/overlapping.data"), + ("delimiter"=",")); +// load second dataset +load dataset UpsertFrom using +localfs(("format"="delimited-text"), + ("path"="asterix_nc1://data/upsert/raw-data/test-data.txt,asterix_nc1://data/upsert/raw-data/more-data.txt"), + ("delimiter"=",")); + +// upsert UpsertFrom into UpsertTo +upsert into UpsertTo( + select value x + from UpsertFrom x +); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.3.query.sqlpp new file mode 100644 index 0000000..102aada --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-btree/primary-secondary-btree.3.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. + */ +/* + * Description : Upsert into a dataset which has a b-tree secondary index + * Expected Res : Success + * Date : Sep 15th 2015 + */ + + // So far this one doesn't use the btree index, need another query +use test; + +select value x +from UpsertTo x +where x.age > 5; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.1.ddl.sqlpp new file mode 100644 index 0000000..e8e421a --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.1.ddl.sqlpp @@ -0,0 +1,37 @@ +/* + * 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. + */ +drop dataverse test if exists; +create dataverse test; +use test; + +create type DBLPType as closed { + id: int64, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create dataset UpsertToDBLP(DBLPType) + primary key id; + +create dataset UpsertFromDBLP(DBLPType) + primary key id; + +create index keyword_index on UpsertToDBLP(title) type keyword; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.2.update.sqlpp new file mode 100644 index 0000000..29a7396 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.2.update.sqlpp @@ -0,0 +1,32 @@ +/* + * 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; + +load dataset UpsertToDBLP +using localfs +(("path"="asterix_nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")); + +load dataset UpsertFromDBLP +using localfs +(("path"="asterix_nc1://data/dblp-small/more-dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")); + +upsert into UpsertToDBLP( + select value x + from UpsertFromDBLP x +); diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.3.query.sqlpp new file mode 100644 index 0000000..31e091c --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-inverted/primary-secondary-inverted.3.query.sqlpp @@ -0,0 +1,24 @@ +/* + * 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; + +SELECT VALUE o +FROM UpsertToDBLP o +WHERE contains(o.title, "SQL") +ORDER BY o.id; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.1.ddl.sqlpp new file mode 100644 index 0000000..01f6725 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.1.ddl.sqlpp @@ -0,0 +1,41 @@ +/* + * 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. + */ +drop dataverse test if exists; +create dataverse test; +use test; + +create type MyRecord as closed { + id: int64, + point: point, + kwds: string, + line1: line, + line2: line, + poly1: polygon, + poly2: polygon, + rec: rectangle, + circle: circle +} + +create dataset UpsertTo(MyRecord) + primary key id; + +create dataset UpsertFrom(MyRecord) + primary key id; + +create index rtree_index_point on UpsertTo(point) type rtree; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.2.update.sqlpp new file mode 100644 index 0000000..b0a3bbc --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.2.update.sqlpp @@ -0,0 +1,32 @@ +/* + * 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; + +load dataset UpsertTo +using localfs +(("path"="asterix_nc1://data/spatial/spatialData.json"),("format"="adm")); + +load dataset UpsertFrom +using localfs +(("path"="asterix_nc1://data/spatial/moreSpatialData.json"),("format"="adm")); + +upsert into UpsertTo( + from UpsertFrom x + select value x +); diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.3.query.sqlpp new file mode 100644 index 0000000..42d4040 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-secondary-rtree/primary-secondary-rtree.3.query.sqlpp @@ -0,0 +1,23 @@ +/* + * 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; + +select o.id +from UpsertTo o +where spatial_intersect(o.point, create_polygon([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0])); diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.1.ddl.sqlpp new file mode 100644 index 0000000..23d3b4d --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.1.ddl.sqlpp @@ -0,0 +1,36 @@ +/* + * 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. + */ +/* + * Description : Upsert into a dataset with self read + * Expected Res : Success + * Date : Sep 15th 2015 + */ + +drop dataverse test if exists; +create dataverse test; +use test; + +create type TestType as closed{ +id:int32, +age:int32, +name:string, +salary:double +}; + +create dataset UpsertTo(TestType) primary key id; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.2.update.sqlpp new file mode 100644 index 0000000..b203673 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.2.update.sqlpp @@ -0,0 +1,36 @@ +/* + * 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. + */ +/* + * Description : Upsert into a dataset with self read + * Expected Res : Success + * Date : Sep 15th 2015 + */ + +use test; +// load first dataset +load dataset UpsertTo using +localfs(("format"="delimited-text"), + ("path"="asterix_nc1://data/upsert/raw-data/overlapping.data"), + ("delimiter"=",")); + +// upsert UpsertFrom into UpsertTo +upsert into UpsertTo( + select x.id as id, x.age+1 as age, x.name as name, x.salary*1.1 as salary + from UpsertTo x +); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.3.query.sqlpp new file mode 100644 index 0000000..e57ea39 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/upsert-with-self-read/upsert-with-self-read.3.query.sqlpp @@ -0,0 +1,28 @@ +/* + * 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. + */ +/* + * Description : Upsert into a dataset with self read + * Expected Res : Success + * Date : Sep 15th 2015 + */ + +use test; + +select value x +from UpsertTo x; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml index 57be018..568877e 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -7645,6 +7645,11 @@ <output-dir compare="Text">issue_230_feeds</output-dir> </compilation-unit> </test-case> + <test-case FilePath="feeds"> + <compilation-unit name="upsert-feed"> + <output-dir compare="Text">upsert-feed</output-dir> + </compilation-unit> + </test-case> </test-group> <test-group name="hdfs"> <test-case FilePath="hdfs"> @@ -8425,4 +8430,61 @@ </compilation-unit> </test-case> </test-group> + <test-group name="upsert"> + <test-case FilePath="upsert"> + <compilation-unit name="filtered-dataset"> + <output-dir compare="Text">filtered-dataset</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="upsert"> + <compilation-unit name="issue1587-foreignDataType"> + <output-dir compare="Text">issue1587-foreignDataType</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="upsert"> + <compilation-unit name="nested-index"> + <output-dir compare="Text">nested-index</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="upsert"> + <compilation-unit name="primary-secondary-rtree"> + <output-dir compare="Text">primary-secondary-rtree</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="upsert"> + <compilation-unit name="upsert-with-self-read"> + <output-dir compare="Text">upsert-with-self-read</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="upsert"> + <compilation-unit name="nullable-index"> + <output-dir compare="Text">nullable-index</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="upsert"> + <compilation-unit name="open-index"> + <output-dir compare="Text">open-index</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="upsert"> + <compilation-unit name="primary-index"> + <output-dir compare="Text">primary-index</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="upsert"> + <compilation-unit name="primary-secondary-btree"> + <output-dir compare="Text">primary-secondary-btree</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="upsert"> + <compilation-unit name="primary-secondary-inverted"> + <output-dir compare="Text">primary-secondary-inverted</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="upsert"> + <compilation-unit name="multiple-secondaries"> + <output-dir compare="Text">multiple-secondaries</output-dir> + </compilation-unit> + </test-case> + </test-group> </test-suite> diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj index ac6083d..60a55a2 100644 --- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj +++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj @@ -120,6 +120,7 @@ import org.apache.asterix.lang.common.statement.TypeDecl; import org.apache.asterix.lang.common.statement.TypeDropStatement; import org.apache.asterix.lang.common.statement.UpdateStatement; +import org.apache.asterix.lang.common.statement.UpsertStatement; import org.apache.asterix.lang.common.statement.WriteStatement; import org.apache.asterix.lang.common.struct.Identifier; import org.apache.asterix.lang.common.struct.QuantifiedPair; @@ -356,6 +357,7 @@ | stmt = InsertStatement() | stmt = DeleteStatement() | stmt = UpdateStatement() + | stmt = UpsertStatement() | stmt = ConnectionStatement() | stmt = CompactStatement() | stmt = ExplainStatement() @@ -970,6 +972,19 @@ { query.setTopLevel(true); return new InsertStatement(nameComponents.first, nameComponents.second, query, getVarCounter(), null, null); + } +} + +UpsertStatement UpsertStatement() throws ParseException: +{ + Pair<Identifier,Identifier> nameComponents = null; + Query query; +} +{ + <UPSERT> <INTO> nameComponents = QualifiedName() query = Query(false) + { + query.setTopLevel(true); + return new UpsertStatement(nameComponents.first, nameComponents.second, query, getVarCounter(), null, null); } } @@ -3131,6 +3146,7 @@ | <UNKOWN : "unknown"> | <UNNEST : "unnest"> | <UPDATE : "update"> + | <UPSERT : "upsert"> | <USE : "use"> | <USING : "using"> | <VALUE : "value"> -- To view, visit https://asterix-gerrit.ics.uci.edu/1401 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I02b2be7ff2653573eccb48037895f5c8c4bc8c74 Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Yingyi Bu <[email protected]>
