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_append function
- user model changes: no - storage format changes: no - interface changes: no details: This is part of implementing array functions. The array_append takes an input list and values to be appended and return a new list with all the values. array_append(list, val1,...) Change-Id: I0a65549957060beee4579b903e6bd323745fb875 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2710 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: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
- Loading branch information
1 parent
baa4b59
commit 5afd9fd
Showing
18 changed files
with
430 additions
and
34 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
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
56 changes: 56 additions & 0 deletions
56
...rc/test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.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,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 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 type t1 AS { | ||
|
||
}; | ||
|
||
create type t2 AS { | ||
id: int, | ||
compType: t1 | ||
}; | ||
|
||
create dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`); | ||
create dataset d1(t2) primary key id; |
27 changes: 27 additions & 0 deletions
27
...test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.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,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. | ||
*/ | ||
|
||
use TinySocial; | ||
|
||
load dataset TweetMessages using localfs ((`path`=`asterix_nc1://data/tinysocial/twm.adm`),(`format`=`adm`)); | ||
|
||
insert into d1([ | ||
{"id":1, "compType":{"sth":33}}, | ||
{"id":2, "compType":{"sth":44}} | ||
]); |
31 changes: 31 additions & 0 deletions
31
.../test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.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,31 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
use TinySocial; | ||
|
||
{ | ||
"t1": (select array_append(t.`referred-topics`, "sth", 5) from TweetMessages t order by t.tweetid), | ||
"t2": (select array_append([3, "John"], (select value v.compType from d1 v))), | ||
"t3": (select array_append([3], 7, null, missing)), | ||
"t4": (select array_append("non_array", 5)), | ||
"t5": (select array_append("non_array", 5, missing)), | ||
"t6": (select array_append([], 5, 10, 12.0, "sth")), | ||
"t7": (select array_append(missing, 3, 9)), | ||
"t8": (select array_append(null, 3, 9)) | ||
}; |
20 changes: 20 additions & 0 deletions
20
...rc/test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.4.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
...sterix-app/src/test/resources/runtimets/results/array_fun/array_append/array_append.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": {{ "t-mobile", "customization", "sth", 5 }} }, { "$1": {{ "verizon", "voice-clarity", "sth", 5 }} }, { "$1": {{ "iphone", "platform", "sth", 5 }} }, { "$1": {{ "samsung", "voice-command", "sth", 5 }} }, { "$1": {{ "verizon", "shortcut-menu", "sth", 5 }} }, { "$1": {{ "motorola", "speed", "sth", 5 }} }, { "$1": {{ "sprint", "voice-command", "sth", 5 }} }, { "$1": {{ "motorola", "speed", "sth", 5 }} }, { "$1": {{ "iphone", "voice-clarity", "sth", 5 }} }, { "$1": {{ "samsung", "platform", "sth", 5 }} }, { "$1": {{ "t-mobile", "shortcut-menu", "sth", 5 }} }, { "$1": {{ "verizon", "voicemail-service", "sth", 5 }} } ], "t2": [ { "$2": [ 3, "John", [ { "sth": 33 }, { "sth": 44 } ] ] } ], "t3": [ { } ], "t4": [ { "$4": null } ], "t5": [ { } ], "t6": [ { "$6": [ 5, 10, 12.0, "sth" ] } ], "t7": [ { } ], "t8": [ { "$8": null } ] } |
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
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
54 changes: 54 additions & 0 deletions
54
...rix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ArrayAppendTypeComputer.java
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,54 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.apache.asterix.om.typecomputer.impl; | ||
|
||
import org.apache.asterix.common.exceptions.CompilationException; | ||
import org.apache.asterix.common.exceptions.ErrorCode; | ||
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; | ||
import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer; | ||
import org.apache.asterix.om.types.ATypeTag; | ||
import org.apache.asterix.om.types.BuiltinType; | ||
import org.apache.asterix.om.types.IAType; | ||
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; | ||
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression; | ||
import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression; | ||
|
||
public class ArrayAppendTypeComputer extends AbstractResultTypeComputer { | ||
|
||
public static final ArrayAppendTypeComputer INSTANCE = new ArrayAppendTypeComputer(); | ||
|
||
@Override | ||
protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException { | ||
if (strippedInputTypes.length < 2) { | ||
String functionName = ((AbstractFunctionCallExpression) expr).getFunctionIdentifier().getName(); | ||
throw new CompilationException(ErrorCode.COMPILATION_INVALID_NUM_OF_ARGS, expr.getSourceLocation(), 2, | ||
functionName); | ||
} | ||
// type tag at [0] should be array or multiset. | ||
ATypeTag typeTag = strippedInputTypes[0].getTypeTag(); | ||
if (typeTag == ATypeTag.ARRAY) { | ||
return DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE; | ||
} else if (typeTag == ATypeTag.MULTISET) { | ||
return DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_TYPE; | ||
} else { | ||
return BuiltinType.ANY; | ||
} | ||
} | ||
} |
Oops, something went wrong.