forked from apache/asterixdb
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NO ISSUE][FUN] Implement array_position function
- user model changes: no - storage format changes: no - interface changes: no details: This is part of implementing array functions. The array_position() takes an input list and a value and returns the index of the value in the array or -1 if the value is not found. array_position(list, val). An error is thrown if val is object or list. Change-Id: I4604d347a22f98071a68abee43693fca9096b361 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2714 Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Reviewed-by: Till Westmann <tillw@apache.org>
- Loading branch information
1 parent
d21c5eb
commit f6b2ade
Showing
16 changed files
with
339 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...est/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.1.ddl.sqlpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
*/ | ||
|
||
drop dataverse TinySocial if exists; | ||
create dataverse TinySocial; | ||
|
||
use TinySocial; | ||
|
||
|
||
create type TinySocial.TwitterUserType as | ||
{ | ||
`screen-name` : string, | ||
lang : string, | ||
friends_count : bigint, | ||
statuses_count : bigint, | ||
name : string, | ||
followers_count : bigint | ||
}; | ||
|
||
create type TinySocial.TweetMessageType as | ||
closed { | ||
tweetid : string, | ||
user : TwitterUserType, | ||
`sender-location` : point?, | ||
`send-time` : datetime, | ||
`referred-topics` : {{string}}, | ||
`message-text` : string | ||
}; | ||
|
||
create dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`); |
22 changes: 22 additions & 0 deletions
22
.../resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.2.update.sqlpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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 TinySocial; | ||
|
||
load dataset TweetMessages using localfs ((`path`=`asterix_nc1://data/tinysocial/twm.adm`),(`format`=`adm`)); |
34 changes: 34 additions & 0 deletions
34
...t/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.3.query.sqlpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* 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 TinySocial; | ||
|
||
{ | ||
"t1": (select array_position(t.`referred-topics`, "speed") from TweetMessages t order by t.tweetid), | ||
"t2": (select array_position([3,8,98,40], 8)), | ||
"t3": (select array_position([3,8,98,40], 40.0)), | ||
"t4": (select array_position([3,8,98,40], -3)), | ||
"t5": (select array_position([3,"sth",98,40], 98)), | ||
"t6": (select array_position([3,8,98,40], null)), | ||
"t7": (select array_position([3,8,98,40], missing)), | ||
"t8": (select array_position(missing, 6)), | ||
"t9": (select array_position(null, 6)), | ||
"t10": (select array_position(5, "sth")), | ||
"t11": (select array_position([5, {"id":77}, "sth"], "sth")) | ||
}; |
22 changes: 22 additions & 0 deletions
22
...t/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.4.query.sqlpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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 TinySocial; | ||
|
||
select array_position([5,1,9], [2,3]); |
22 changes: 22 additions & 0 deletions
22
...t/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.5.query.sqlpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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 TinySocial; | ||
|
||
select array_position([5,{"id": 5},9], {"id": 5}); |
20 changes: 20 additions & 0 deletions
20
...est/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.6.ddl.sqlpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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 TinySocial; |
1 change: 1 addition & 0 deletions
1
...ix-app/src/test/resources/runtimets/results/array_fun/array_position/array_position.3.adm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "t1": [ { "$1": -1 }, { "$1": -1 }, { "$1": -1 }, { "$1": -1 }, { "$1": -1 }, { "$1": 1 }, { "$1": -1 }, { "$1": 1 }, { "$1": -1 }, { "$1": -1 }, { "$1": -1 }, { "$1": -1 } ], "t2": [ { "$2": 1 } ], "t3": [ { "$3": 3 } ], "t4": [ { "$4": -1 } ], "t5": [ { "$5": 2 } ], "t6": [ { "$6": null } ], "t7": [ { } ], "t8": [ { } ], "t9": [ { "$9": null } ], "t10": [ { "$10": null } ], "t11": [ { "$11": 2 } ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.