Changeset: 74472cc5e35d for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=74472cc5e35d Added Files: sql/test/sciql2sql/Tests/slice_2d_array.sql Modified Files: sql/test/sciql2sql/Tests/All Branch: SciQL-2 Log Message:
Direct slicing of an array diffs (97 lines): diff --git a/sql/test/sciql2sql/Tests/All b/sql/test/sciql2sql/Tests/All --- a/sql/test/sciql2sql/Tests/All +++ b/sql/test/sciql2sql/Tests/All @@ -8,6 +8,7 @@ create_unbound_step_array # update attributes update_fixed_array + #update_range_array covered by fixed_array update_unbound_array update_step_int_array @@ -15,11 +16,12 @@ update_unbound_step_array # slice selections with target is relation slice_fixed_array -#show slice/dice over arrays -# -# selection with array is arrays +slice_2d_array + + +# selection with array type result # tiling based on dimensional attributes -# vector manipulations vector_fixed_tiles +# # tiling based on mix of dimensional attribues diff --git a/sql/test/sciql2sql/Tests/slice_2d_array.sql b/sql/test/sciql2sql/Tests/slice_2d_array.sql new file mode 100644 --- /dev/null +++ b/sql/test/sciql2sql/Tests/slice_2d_array.sql @@ -0,0 +1,64 @@ +-- a 2 Dimensional fixed array +CREATE ARRAY array2D(x TINYINT DIMENSION[4], y BIGINT DIMENSION[4], v INTEGER DEFAULT 2); +SELECT * FROM array2D; +DROP ARRAY array2D; + +-- relational equivalent +CREATE TABLE matrix(x TINYINT CHECK(x >=0 and x < 4), y BIGINT CHECK( y>=0 and y<4), v INTEGER DEFAULT 2); +INSERT INTO matrix values +( 0, 0, 2 ), +( 0, 1, 2 ), +( 0, 2, 2 ), +( 0, 3, 2 ), +( 1, 0, 2 ), +( 1, 1, 2 ), +( 1, 2, 2 ), +( 1, 3, 2 ), +( 2, 0, 2 ), +( 2, 1, 2 ), +( 2, 2, 2 ), +( 2, 3, 2 ), +( 3, 0, 2 ), +( 3, 1, 2 ), +( 3, 2, 2 ), +( 3, 3, 2 ); + +-- point slicing +SELECT * FROM array2D[0][0]; +SELECT * FROM array2D[1][1]; + +-- relational +SELECT * FROM matrix WHERE x= 0 AND y = 0; +SELECT * FROM matrix WHERE x= 1 AND y = 1; + +-- row and col based selection +SELECT * FROM array2D[0][*]; +SELECT * FROM array2D[*][1]; + +-- relational +SELECT * FROM matrix WHERE x = 0; +SELECT * FROM matrix WHERE y = 1; + +-- ideally we should use variables +DECLARE xval INTEGER; +DECLARE yval INTEGER; +SET xval =1; +SET yval =1; + +SELECT * FROM array2D[xval][*]; +SELECT * FROM array2D[*][yval]; + +-- same answer as before + + +-- extracting a chuck +SELECT * FROM array2D[xval:xval+2][yval:yval+3]; + +-- relational equivalent +SELECT * FROM matrix WHERE x>= xval AND x < xval+2 AND y >=yval AND y < yval +3; + +DROP ARRAY array2D; +DROP TABLE matrix; + + +-- Semantic arrors _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list