Skip to content

Commit

Permalink
[AD-604] Query execution adaption (#57)
Browse files Browse the repository at this point in the history
### Summary

[AD-604] Query execution adaption

### Description

- Use JNI call to DocumentDbQueryMappingService to get the aggregate command pipeline.
- Call server using mongocxx library
- Map the result cursor so data_query returns the results - properly converted for query column metadata.
- Ensure to handle null/missing elements in the query result.

Ensure tests for:
- [x] single row, SQLBindCol and SQLGetData
- [x] multiple rows
- [x] null/missing values
- [x] array field
- [x] sub-document field

### Related Issue

https://bitquill.atlassian.net/browse/AD-604* [AD-604] Query execution adaption

* [AD-604] Query execution adaption
* Initial commit. 6 memory leaks detected.

* [AD-604] Query execution adaption
* Handle non-existent element in document.

* [AD-604] Query execution adaption
* Remove debugging code
* Add tests (part 1)
* Change import script to handle "jsonArray".

* [AD-604] Query execution adaption
* Add tests

* [AD-604] Query execution adaption
* Remove use of std::make_unique.

* [AD-604] Query execution adaption
* Fix import script.

* [AD-604] Query execution adaption
* Clean-up

* [AD-604] Query execution adaption
* Clean-up

* [AD-604] Query execution adaption
* Correct line endings.

* [AD-604] Query execution adaption
* Refactor class field names.

* [AD-604] Query execution adaption
* Fixed iterating over cursor - fixed memory leak.

* [AD-604] Query execution adaption
* Improvements from code review comments.

* [AD-604] Query execution adaption
* Improvements from code review comments.

* [AD-604] Query execution adaption
* Improvements from code review comments.
  • Loading branch information
Bruce Irschick authored Apr 1, 2022
1 parent 1b8ae03 commit a206b45
Show file tree
Hide file tree
Showing 39 changed files with 2,463 additions and 1,539 deletions.
4 changes: 3 additions & 1 deletion src/odbc-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ set(SOURCES
../odbc/src/diagnostic/diagnosable_adapter.cpp
../odbc/src/diagnostic/diagnostic_record_storage.cpp
../odbc/src/diagnostic/diagnostic_record.cpp
../odbc/src/documentdb_column.cpp
../odbc/src/documentdb_cursor.cpp
../odbc/src/documentdb_row.cpp
../odbc/src/dsn_config.cpp
../odbc/src/environment.cpp
../odbc/src/ignite_error.cpp
Expand All @@ -113,7 +116,6 @@ set(SOURCES
../odbc/src/query/foreign_keys_query.cpp
../odbc/src/query/primary_keys_query.cpp
../odbc/src/query/special_columns_query.cpp
../odbc/src/query/streaming_query.cpp
../odbc/src/query/type_info_query.cpp
../odbc/src/query/table_metadata_query.cpp
../odbc/src/sql/sql_lexer.cpp
Expand Down
3 changes: 2 additions & 1 deletion src/odbc-test/include/odbc_test_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ struct OdbcTestSuite {
void CreateDsnConnectionStringForRemoteServer(
std::string& connectionString, bool sshTunnel = true,
const std::string& username = std::string(),
const std::string& miscOptions = std::string()) const;
const std::string& miscOptions = std::string(),
const std::string databasename = std::string()) const;

/**
* Creates the standard DSN connection string for use with local instance.
Expand Down
66 changes: 34 additions & 32 deletions src/odbc-test/input/api_robustness_test_001.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"_id":{
"$oid":"62196dcc4d91892191475139"
},
"fieldDecimal128":{
"$numberDecimal":"Infinity"
},
"fieldDouble":1.7976931348623157E308,
"fieldString":"新年快乐",
"fieldObjectId":{
"$oid":"62196dcc4d9189219147513a"
},
"fieldBoolean":true,
"fieldDate":{
"$date":"2020-01-01T00:00:00Z"
},
"fieldInt":2147483647,
"fieldLong":9223372036854775807,
"fieldMaxKey":{
"$maxKey":1
},
"fieldMinKey":{
"$minKey":1
},
"fieldNull":null,
"fieldBinary":{
"$binary":{
"base64":"AAEC",
"subType":"00"
}
}
}
[
{
"_id": {
"$oid": "62196dcc4d91892191475139"
},
"fieldDecimal128": {
"$numberDecimal": "Infinity"
},
"fieldDouble": 1.7976931348623157E308,
"fieldString": "新年快乐",
"fieldObjectId": {
"$oid": "62196dcc4d9189219147513a"
},
"fieldBoolean": true,
"fieldDate": {
"$date": "2020-01-01T00:00:00Z"
},
"fieldInt": 2147483647,
"fieldLong": 9223372036854775807,
"fieldMaxKey": {
"$maxKey": 1
},
"fieldMinKey": {
"$minKey": 1
},
"fieldNull": null,
"fieldBinary": {
"$binary": {
"base64": "AAEC",
"subType": "00"
}
}
}
]
66 changes: 34 additions & 32 deletions src/odbc-test/input/jni_test_001.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"_id":{
"$oid":"62196dcc4d91892191475139"
},
"fieldDecimal128":{
"$numberDecimal":"Infinity"
},
"fieldDouble":1.7976931348623157E308,
"fieldString":"新年快乐",
"fieldObjectId":{
"$oid":"62196dcc4d9189219147513a"
},
"fieldBoolean":true,
"fieldDate":{
"$date":"2020-01-01T00:00:00Z"
},
"fieldInt":2147483647,
"fieldLong":9223372036854775807,
"fieldMaxKey":{
"$maxKey":1
},
"fieldMinKey":{
"$minKey":1
},
"fieldNull":null,
"fieldBinary":{
"$binary":{
"base64":"AAEC",
"subType":"00"
}
}
}
[
{
"_id": {
"$oid": "62196dcc4d91892191475139"
},
"fieldDecimal128": {
"$numberDecimal": "Infinity"
},
"fieldDouble": 1.7976931348623157E308,
"fieldString": "新年快乐",
"fieldObjectId": {
"$oid": "62196dcc4d9189219147513a"
},
"fieldBoolean": true,
"fieldDate": {
"$date": "2020-01-01T00:00:00Z"
},
"fieldInt": 2147483647,
"fieldLong": 9223372036854775807,
"fieldMaxKey": {
"$maxKey": 1
},
"fieldMinKey": {
"$minKey": 1
},
"fieldNull": null,
"fieldBinary": {
"$binary": {
"base64": "AAEC",
"subType": "00"
}
}
}
]
66 changes: 34 additions & 32 deletions src/odbc-test/input/meta_queries_test_001.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"_id":{
"$oid":"62196dcc4d91892191475139"
},
"fieldDecimal128":{
"$numberDecimal":"Infinity"
},
"fieldDouble":1.7976931348623157E308,
"fieldString":"新年快乐",
"fieldObjectId":{
"$oid":"62196dcc4d9189219147513a"
},
"fieldBoolean":true,
"fieldDate":{
"$date":"2020-01-01T00:00:00Z"
},
"fieldInt":2147483647,
"fieldLong":9223372036854775807,
"fieldMaxKey":{
"$maxKey":1
},
"fieldMinKey":{
"$minKey":1
},
"fieldNull":null,
"fieldBinary":{
"$binary":{
"base64":"AAEC",
"subType":"00"
}
}
}
[
{
"_id": {
"$oid": "62196dcc4d91892191475139"
},
"fieldDecimal128": {
"$numberDecimal": "Infinity"
},
"fieldDouble": 1.7976931348623157E308,
"fieldString": "新年快乐",
"fieldObjectId": {
"$oid": "62196dcc4d9189219147513a"
},
"fieldBoolean": true,
"fieldDate": {
"$date": "2020-01-01T00:00:00Z"
},
"fieldInt": 2147483647,
"fieldLong": 9223372036854775807,
"fieldMaxKey": {
"$maxKey": 1
},
"fieldMinKey": {
"$minKey": 1
},
"fieldNull": null,
"fieldBinary": {
"$binary": {
"base64": "AAEC",
"subType": "00"
}
}
}
]
64 changes: 33 additions & 31 deletions src/odbc-test/input/meta_queries_test_002.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"_id":{
"$oid":"8888f88886afa51ac62bed23"
},
"fieldDecimal128":{
"$numberDecimal":"Infinity"
},
"fieldDouble":3.1415926E23,
"fieldString":"こんにちは",
"fieldObjectId":{
"$oid":"888888caabcdef8888888888"
},
"fieldBoolean":false,
"fieldDate":{
"$date":"2022-03-08T00:00:00Z"
},
"fieldInt":21345621,
"fieldLong":9281883193847263322,
"fieldMaxKey":{
"$maxKey":1
},
"fieldMinKey":{
"$minKey":1
},
"fieldNull":null,
"fieldBinary":{
"$binary":{
"base64":"AAEC",
"subType":"00"
[
{
"_id": {
"$oid": "8888f88886afa51ac62bed23"
},
"fieldDecimal128": {
"$numberDecimal": "Infinity"
},
"fieldDouble": 3.1415926E23,
"fieldString": "こんにちは",
"fieldObjectId": {
"$oid": "888888caabcdef8888888888"
},
"fieldBoolean": false,
"fieldDate": {
"$date": "2022-03-08T00:00:00Z"
},
"fieldInt": 21345621,
"fieldLong": 9281883193847263322,
"fieldMaxKey": {
"$maxKey": 1
},
"fieldMinKey": {
"$minKey": 1
},
"fieldNull": null,
"fieldBinary": {
"$binary": {
"base64": "AAEC",
"subType": "00"
}
}
}
}
}
]
66 changes: 34 additions & 32 deletions src/odbc-test/input/queries_test_001.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"_id":{
"$oid":"62196dcc4d91892191475139"
},
"fieldDecimal128":{
"$numberDecimal":"Infinity"
},
"fieldDouble":1.7976931348623157E308,
"fieldString":"新年快乐",
"fieldObjectId":{
"$oid":"62196dcc4d9189219147513a"
},
"fieldBoolean":true,
"fieldDate":{
"$date":"2020-01-01T00:00:00Z"
},
"fieldInt":2147483647,
"fieldLong":9223372036854775807,
"fieldMaxKey":{
"$maxKey":1
},
"fieldMinKey":{
"$minKey":1
},
"fieldNull":null,
"fieldBinary":{
"$binary":{
"base64":"AAEC",
"subType":"00"
}
}
}
[
{
"_id": {
"$oid": "62196dcc4d91892191475139"
},
"fieldDecimal128": {
"$numberDecimal": "3.4028235e20"
},
"fieldDouble": 1.7976931348623157E308,
"fieldString": "some Text",
"fieldObjectId": {
"$oid": "62196dcc4d9189219147513a"
},
"fieldBoolean": true,
"fieldDate": {
"$date": "2020-01-01T00:00:00Z"
},
"fieldInt": 2147483647,
"fieldLong": 9223372036854775807,
"fieldMaxKey": {
"$maxKey": 1
},
"fieldMinKey": {
"$minKey": 1
},
"fieldNull": null,
"fieldBinary": {
"$binary": {
"base64": "AAEC",
"subType": "00"
}
}
}
]
Loading

0 comments on commit a206b45

Please sign in to comment.