Skip to content

Commit

Permalink
Agtype hash cmp (#1893)
Browse files Browse the repository at this point in the history
* Order some regression tests for stability on big-endian

On Debian's s390x architecture, some regression tests were failing
because the result set was reordered. Fix by attaching ORDER BY in
problematic cases.

* Move agtype_hash_cmp tests to separate file

Output of the agtype_hash_cmp function varies depending on the machine
endianness. Move tests to a separate file and supply little-endian and
big-endian output expected files.
  • Loading branch information
df7cb committed May 23, 2024
1 parent 3b8aaa6 commit ef9e0bd
Show file tree
Hide file tree
Showing 6 changed files with 437 additions and 200 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ DATA_built = $(age_sql)
REGRESS = scan \
graphid \
agtype \
agtype_hash_cmp \
catalog \
cypher \
expr \
Expand Down
163 changes: 0 additions & 163 deletions regress/expected/agtype.out
Original file line number Diff line number Diff line change
Expand Up @@ -3577,169 +3577,6 @@ SELECT agtype_string_match_contains('"abcdefghijklmnopqrstuvwxyz"', '"hijl"');
false
(1 row)

--Agtype Hash Comparison Function
SELECT agtype_hash_cmp(NULL);
agtype_hash_cmp
-----------------
0
(1 row)

SELECT agtype_hash_cmp('1'::agtype);
agtype_hash_cmp
-----------------
-123017199
(1 row)

SELECT agtype_hash_cmp('1.0'::agtype);
agtype_hash_cmp
-----------------
614780178
(1 row)

SELECT agtype_hash_cmp('"1"'::agtype);
agtype_hash_cmp
-----------------
-888576106
(1 row)

SELECT agtype_hash_cmp('[1]'::agtype);
agtype_hash_cmp
-----------------
434414509
(1 row)

SELECT agtype_hash_cmp('[1, 1]'::agtype);
agtype_hash_cmp
-----------------
-1551022880
(1 row)

SELECT agtype_hash_cmp('[1, 1, 1]'::agtype);
agtype_hash_cmp
-----------------
-3900769
(1 row)

SELECT agtype_hash_cmp('[1, 1, 1, 1]'::agtype);
agtype_hash_cmp
-----------------
1756986519
(1 row)

SELECT agtype_hash_cmp('[1, 1, 1, 1, 1]'::agtype);
agtype_hash_cmp
-----------------
-47741579
(1 row)

SELECT agtype_hash_cmp('[[1]]'::agtype);
agtype_hash_cmp
-----------------
878744030
(1 row)

SELECT agtype_hash_cmp('[[1, 1]]'::agtype);
agtype_hash_cmp
-----------------
-1254522284
(1 row)

SELECT agtype_hash_cmp('[[1], 1]'::agtype);
agtype_hash_cmp
-----------------
-1005036
(1 row)

SELECT agtype_hash_cmp('[1543872]'::agtype);
agtype_hash_cmp
-----------------
-1925093371
(1 row)

SELECT agtype_hash_cmp('[1, "abcde", 2.0]'::agtype);
agtype_hash_cmp
-----------------
-1128310748
(1 row)

SELECT agtype_hash_cmp(agtype_in('null'));
agtype_hash_cmp
-----------------
-505290271
(1 row)

SELECT agtype_hash_cmp(agtype_in('[null]'));
agtype_hash_cmp
-----------------
505290241
(1 row)

SELECT agtype_hash_cmp(agtype_in('[null, null]'));
agtype_hash_cmp
-----------------
3
(1 row)

SELECT agtype_hash_cmp(agtype_in('[null, null, null]'));
agtype_hash_cmp
-----------------
2021160967
(1 row)

SELECT agtype_hash_cmp(agtype_in('[null, null, null, null]'));
agtype_hash_cmp
-----------------
15
(1 row)

SELECT agtype_hash_cmp(agtype_in('[null, null, null, null, null]'));
agtype_hash_cmp
-----------------
-505290721
(1 row)

SELECT agtype_hash_cmp('{"id":1, "label":"test", "properties":{"id":100}}'::agtype);
agtype_hash_cmp
-----------------
1116453668
(1 row)

SELECT agtype_hash_cmp('{"id":1, "label":"test", "properties":{"id":100}}::vertex'::agtype);
agtype_hash_cmp
-----------------
1848106598
(1 row)

SELECT agtype_hash_cmp('{"id":2, "start_id":1, "end_id": 3, "label":"elabel", "properties":{}}'::agtype);
agtype_hash_cmp
-----------------
1064722414
(1 row)

SELECT agtype_hash_cmp('{"id":2, "start_id":1, "end_id": 3, "label":"elabel", "properties":{}}::edge'::agtype);
agtype_hash_cmp
-----------------
-1790838958
(1 row)

SELECT agtype_hash_cmp('
[{"id":1, "label":"test", "properties":{"id":100}}::vertex,
{"id":2, "start_id":1, "end_id": 3, "label":"elabel", "properties":{}}::edge,
{"id":5, "label":"vlabel", "properties":{}}::vertex]'::agtype);
agtype_hash_cmp
-----------------
-231467898
(1 row)

SELECT agtype_hash_cmp('
[{"id":1, "label":"test", "properties":{"id":100}}::vertex,
{"id":2, "start_id":1, "end_id": 3, "label":"elabel", "properties":{}}::edge,
{"id":5, "label":"vlabel", "properties":{}}::vertex]::path'::agtype);
agtype_hash_cmp
-----------------
843330291
(1 row)

--Agtype BTree Comparison Function
SELECT agtype_btree_cmp('1'::agtype, '1'::agtype);
agtype_btree_cmp
Expand Down
187 changes: 187 additions & 0 deletions regress/expected/agtype_hash_cmp.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/*
* 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.
*/
--
-- AGTYPE data type regression tests
--
SET search_path TO ag_catalog;
-- Agtype Hash Comparison Function
-- Result value varies depending on architecture endianness.
-- Little endian output is in agtype_hash_cmp.out; big endian in agtype_hash_cmp_1.out.
SELECT agtype_hash_cmp(NULL);
agtype_hash_cmp
-----------------
0
(1 row)

SELECT agtype_hash_cmp('1'::agtype);
agtype_hash_cmp
-----------------
-123017199
(1 row)

SELECT agtype_hash_cmp('1.0'::agtype);
agtype_hash_cmp
-----------------
614780178
(1 row)

SELECT agtype_hash_cmp('"1"'::agtype);
agtype_hash_cmp
-----------------
-888576106
(1 row)

SELECT agtype_hash_cmp('[1]'::agtype);
agtype_hash_cmp
-----------------
434414509
(1 row)

SELECT agtype_hash_cmp('[1, 1]'::agtype);
agtype_hash_cmp
-----------------
-1551022880
(1 row)

SELECT agtype_hash_cmp('[1, 1, 1]'::agtype);
agtype_hash_cmp
-----------------
-3900769
(1 row)

SELECT agtype_hash_cmp('[1, 1, 1, 1]'::agtype);
agtype_hash_cmp
-----------------
1756986519
(1 row)

SELECT agtype_hash_cmp('[1, 1, 1, 1, 1]'::agtype);
agtype_hash_cmp
-----------------
-47741579
(1 row)

SELECT agtype_hash_cmp('[[1]]'::agtype);
agtype_hash_cmp
-----------------
878744030
(1 row)

SELECT agtype_hash_cmp('[[1, 1]]'::agtype);
agtype_hash_cmp
-----------------
-1254522284
(1 row)

SELECT agtype_hash_cmp('[[1], 1]'::agtype);
agtype_hash_cmp
-----------------
-1005036
(1 row)

SELECT agtype_hash_cmp('[1543872]'::agtype);
agtype_hash_cmp
-----------------
-1925093371
(1 row)

SELECT agtype_hash_cmp('[1, "abcde", 2.0]'::agtype);
agtype_hash_cmp
-----------------
-1128310748
(1 row)

SELECT agtype_hash_cmp(agtype_in('null'));
agtype_hash_cmp
-----------------
-505290271
(1 row)

SELECT agtype_hash_cmp(agtype_in('[null]'));
agtype_hash_cmp
-----------------
505290241
(1 row)

SELECT agtype_hash_cmp(agtype_in('[null, null]'));
agtype_hash_cmp
-----------------
3
(1 row)

SELECT agtype_hash_cmp(agtype_in('[null, null, null]'));
agtype_hash_cmp
-----------------
2021160967
(1 row)

SELECT agtype_hash_cmp(agtype_in('[null, null, null, null]'));
agtype_hash_cmp
-----------------
15
(1 row)

SELECT agtype_hash_cmp(agtype_in('[null, null, null, null, null]'));
agtype_hash_cmp
-----------------
-505290721
(1 row)

SELECT agtype_hash_cmp('{"id":1, "label":"test", "properties":{"id":100}}'::agtype);
agtype_hash_cmp
-----------------
1116453668
(1 row)

SELECT agtype_hash_cmp('{"id":1, "label":"test", "properties":{"id":100}}::vertex'::agtype);
agtype_hash_cmp
-----------------
1848106598
(1 row)

SELECT agtype_hash_cmp('{"id":2, "start_id":1, "end_id": 3, "label":"elabel", "properties":{}}'::agtype);
agtype_hash_cmp
-----------------
1064722414
(1 row)

SELECT agtype_hash_cmp('{"id":2, "start_id":1, "end_id": 3, "label":"elabel", "properties":{}}::edge'::agtype);
agtype_hash_cmp
-----------------
-1790838958
(1 row)

SELECT agtype_hash_cmp('
[{"id":1, "label":"test", "properties":{"id":100}}::vertex,
{"id":2, "start_id":1, "end_id": 3, "label":"elabel", "properties":{}}::edge,
{"id":5, "label":"vlabel", "properties":{}}::vertex]'::agtype);
agtype_hash_cmp
-----------------
-231467898
(1 row)

SELECT agtype_hash_cmp('
[{"id":1, "label":"test", "properties":{"id":100}}::vertex,
{"id":2, "start_id":1, "end_id": 3, "label":"elabel", "properties":{}}::edge,
{"id":5, "label":"vlabel", "properties":{}}::vertex]::path'::agtype);
agtype_hash_cmp
-----------------
843330291
(1 row)

Loading

0 comments on commit ef9e0bd

Please sign in to comment.