Skip to content

Commit c10ef48

Browse files
committed
Fill in WHERE a IS NOT NULL example
1 parent ad3f43c commit c10ef48

File tree

1 file changed

+100
-61
lines changed

1 file changed

+100
-61
lines changed

test/src/unit-query-add-predicate.cc

Lines changed: 100 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -96,65 +96,72 @@ struct QueryAddPredicateFx {
9696
static const Cells INPUT;
9797
};
9898

99-
const Cells QueryAddPredicateFx::INPUT = Cells{
100-
.d1_ = templates::query_buffers<uint64_t>(
101-
{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4}),
102-
.d2_ = templates::query_buffers<uint64_t>(
103-
{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}),
104-
.atts_ = std::make_tuple(
105-
templates::query_buffers<std::optional<int32_t>>(
106-
std::vector<std::optional<int32_t>>{
107-
15,
108-
std::nullopt,
109-
std::nullopt,
110-
12,
111-
std::nullopt,
112-
10,
113-
9,
114-
std::nullopt,
115-
7,
116-
6,
117-
5,
118-
4,
119-
std::nullopt,
120-
2,
121-
1,
122-
0}),
123-
templates::query_buffers<std::string>(std::vector<std::string>{
124-
"one",
125-
"two",
126-
"three",
127-
"four",
128-
"five",
129-
"six",
130-
"seven",
131-
"eight",
132-
"nine",
133-
"ten",
134-
"eleven",
135-
"twelve",
136-
"thirteen",
137-
"fourteen",
138-
"fifteen",
139-
"sixteen"}),
140-
templates::query_buffers<std::optional<int32_t>>(
141-
std::vector<std::optional<int32_t>>{
142-
4,
143-
4,
144-
7,
145-
std::nullopt,
146-
7,
147-
7,
148-
std::nullopt,
149-
0,
150-
1,
151-
std::nullopt,
152-
3,
153-
4,
154-
std::nullopt,
155-
6,
156-
7,
157-
std::nullopt}))};
99+
static Cells make_cells(
100+
std::vector<uint64_t> d1,
101+
std::vector<uint64_t> d2,
102+
std::vector<std::optional<int32_t>> a,
103+
std::vector<std::string> v,
104+
std::vector<std::optional<int32_t>> e) {
105+
return Cells{
106+
.d1_ = templates::query_buffers<uint64_t>(d1),
107+
.d2_ = templates::query_buffers<uint64_t>(d2),
108+
.atts_ = std::make_tuple(
109+
templates::query_buffers<std::optional<int32_t>>(a),
110+
templates::query_buffers<std::string>(v),
111+
templates::query_buffers<std::optional<int32_t>>(e))};
112+
}
113+
114+
const Cells QueryAddPredicateFx::INPUT = make_cells(
115+
{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4},
116+
{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4},
117+
{15,
118+
std::nullopt,
119+
std::nullopt,
120+
12,
121+
std::nullopt,
122+
10,
123+
9,
124+
std::nullopt,
125+
7,
126+
6,
127+
5,
128+
4,
129+
std::nullopt,
130+
2,
131+
1,
132+
0},
133+
{"one",
134+
"two",
135+
"three",
136+
"four",
137+
"five",
138+
"six",
139+
"seven",
140+
"eight",
141+
"nine",
142+
"ten",
143+
"eleven",
144+
"twelve",
145+
"thirteen",
146+
"fourteen",
147+
"fifteen",
148+
"sixteen"},
149+
{4,
150+
4,
151+
7,
152+
std::nullopt,
153+
7,
154+
7,
155+
std::nullopt,
156+
0,
157+
1,
158+
std::nullopt,
159+
3,
160+
4,
161+
std::nullopt,
162+
6,
163+
7,
164+
std::nullopt});
158165

159166
void QueryAddPredicateFx::create_array(
160167
const std::string& path, tiledb_array_type_t atype) {
@@ -424,8 +431,40 @@ TEST_CASE_METHOD(
424431
CHECK(result == INPUT);
425432
}
426433

427-
SECTION("WHERE a IS NULL") {
428-
// TODO
434+
SECTION("WHERE a IS NOT NULL") {
435+
const Cells expect = make_cells(
436+
{1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4},
437+
{1, 4, 2, 3, 1, 2, 3, 4, 2, 3, 4},
438+
{15, 12, 10, 9, 7, 6, 5, 4, 2, 1, 0},
439+
{"one",
440+
"four",
441+
"six",
442+
"seven",
443+
"nine",
444+
"ten",
445+
"eleven",
446+
"twelve",
447+
"fourteen",
448+
"fifteen",
449+
"sixteen"},
450+
{4,
451+
std::nullopt,
452+
7,
453+
std::nullopt,
454+
1,
455+
std::nullopt,
456+
3,
457+
4,
458+
6,
459+
7,
460+
std::nullopt});
461+
const auto result =
462+
query_array(array_name, TILEDB_GLOBAL_ORDER, "a IS NOT NULL");
463+
CHECK(result.d1_ == expect.d1_);
464+
CHECK(result.d2_ == expect.d2_);
465+
CHECK(std::get<0>(result.atts_) == std::get<0>(expect.atts_));
466+
CHECK(std::get<1>(result.atts_) == std::get<1>(expect.atts_));
467+
CHECK(std::get<2>(result.atts_) == std::get<2>(expect.atts_));
429468
}
430469

431470
SECTION("WHERE b < 'fourteen'") {

0 commit comments

Comments
 (0)