@@ -9,6 +9,8 @@ local collations = require('crud.common.collations')
9
9
local t = require (' luatest' )
10
10
local g = t .group (' select_filters' )
11
11
12
+ local crud_utils = require (' crud.common.utils' )
13
+
12
14
local helpers = require (' test.helper' )
13
15
14
16
g .before_all = function ()
@@ -43,10 +45,47 @@ g.before_all = function()
43
45
unique = false ,
44
46
if_not_exists = true ,
45
47
})
48
+
49
+ if crud_utils .tarantool_supports_jsonpath_indexes () then
50
+ local cars_space = box .schema .space .create (' cars' , {
51
+ format = {
52
+ {name = ' id' , type = ' map' },
53
+ {name = ' bucket_id' , type = ' unsigned' },
54
+ {name = ' age' , type = ' number' },
55
+ {name = ' manufacturer' , type = ' string' },
56
+ {name = ' data' , type = ' map' }
57
+ },
58
+ if_not_exists = true ,
59
+ })
60
+
61
+ -- primary index
62
+ cars_space :create_index (' id_ind' , {
63
+ parts = {
64
+ {1 , ' unsigned' , path = ' car_id.signed' },
65
+ },
66
+ if_not_exists = true ,
67
+ })
68
+
69
+ cars_space :create_index (' bucket_id' , {
70
+ parts = { ' bucket_id' },
71
+ unique = false ,
72
+ if_not_exists = true ,
73
+ })
74
+
75
+ cars_space :create_index (' data_index' , {
76
+ parts = {
77
+ {5 , ' str' , path = ' car.color' },
78
+ {5 , ' str' , path = ' car.model' },
79
+ },
80
+ unique = false ,
81
+ if_not_exists = true ,
82
+ })
83
+ end
46
84
end
47
85
48
86
g .after_all (function ()
49
87
box .space .customers :drop ()
88
+ box .space .cars :drop ()
50
89
end )
51
90
52
91
g .test_empty_conditions = function ()
@@ -815,5 +854,34 @@ return M]]
815
854
t .assert_equals ({ filter_func (box .tuple .new ({{field_1 = 5 , f2 = 3 }, {fld_1 = " jsonpath_test" }, 23 })) }, {false , false })
816
855
end
817
856
857
+ g .test_jsonpath_indexes = function ()
858
+ t .skip_if (
859
+ not crud_utils .tarantool_supports_jsonpath_indexes (),
860
+ " Jsonpath indexes supported since 2.6.3/2.7.2/2.8.1"
861
+ )
862
+
863
+ local conditions = {
864
+ cond_funcs .gt (' id' , 20 ),
865
+ cond_funcs .eq (' data_index' , {' Yellow' , ' BMW' })
866
+ }
867
+
868
+ local plan , err = select_plan .new (box .space .cars , conditions )
869
+ t .assert_equals (err , nil )
870
+
871
+ local filter_conditions , err = select_filters .internal .parse (box .space .cars , conditions , {
872
+ scan_condition_num = plan .scan_condition_num ,
873
+ tarantool_iter = plan .tarantool_iter ,
874
+ })
875
+
876
+ t .assert_equals (err , nil )
877
+
878
+ local data_condition = filter_conditions [1 ]
879
+ t .assert_type (data_condition , ' table' )
880
+ t .assert_equals (data_condition .fields , {" [5]car.color" , " [5]car.model" })
881
+ t .assert_equals (data_condition .operator , compare_conditions .operators .EQ )
882
+ t .assert_equals (data_condition .values , {' Yellow' , ' BMW' })
883
+ t .assert_equals (data_condition .types , {' string' , ' string' })
884
+ t .assert_equals (data_condition .early_exit_is_possible , false )
885
+ end
818
886
819
887
-- luacheck: pop
0 commit comments