-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocumentdb_smoke_test.cpp
More file actions
34 lines (28 loc) · 1.17 KB
/
Copy pathdocumentdb_smoke_test.cpp
File metadata and controls
34 lines (28 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "documentdb/documentdb.hpp"
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
int main() {
documentdb::ConnectionConfig cfg;
cfg.host = "localhost";
cfg.port = 27017;
cfg.database = "app";
const std::vector<std::string> sample_docs = {
R"({"_id": 1, "status": "active", "total": 99.5})",
R"({"_id": 2, "status": "pending", "total": 49.0, "metadata": {"region": "east,us"}})"
};
auto schema = documentdb::SchemaResolver::infer_from_samples(sample_docs);
assert(schema.size() >= 3);
assert(std::find_if(schema.begin(), schema.end(), [](const documentdb::FieldType& field) {
return field.name == "status" && field.duckdb_type == "VARCHAR";
}) != schema.end());
assert(std::find_if(schema.begin(), schema.end(), [](const documentdb::FieldType& field) {
return field.name == "metadata" && field.duckdb_type == "VARCHAR";
}) != schema.end());
auto plan = documentdb::ScanPlanner::plan("orders", "{\"status\": \"active\"}", {"_id", "status"}, 10);
assert(plan.collection_name == "orders");
assert(plan.limit == 10);
assert(plan.projections.size() == 2);
return 0;
}