generated from duckdb/extension-template
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Result Serialization #26
Merged
lmangani
merged 11 commits into
quackscience:main
from
gropaul:pgross/new-result-serializer
Dec 23, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7a9c044
added result serializer
gropaul e9aea60
fixed some bugs for exotic types
gropaul 053b45e
use internal function for type names
gropaul 3546724
added missing cmath include
gropaul 6ed4507
Added e2e tests
NiclasHaderer f6fc570
Cleanup
NiclasHaderer f10d81a
Moved up clang-format and tidy config so IDE and make format picks up…
NiclasHaderer 038ad50
Moved most logic into new compact serializer
NiclasHaderer 6712cec
Added some docs for contributing
NiclasHaderer 816606f
Ignore pycache
NiclasHaderer 6a0a3d6
Cleanup
NiclasHaderer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
duckdb/.clang-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
duckdb/.clang-tidy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ duckdb_unittest_tempdir/ | |
testext | ||
test/python/__pycache__/ | ||
.Rhistory | ||
__pycache__ | ||
venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
httpx==0.28.1 | ||
pytest==8.3.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#pragma once | ||
|
||
#include "duckdb.hpp" | ||
#include "duckdb/common/file_system.hpp" | ||
|
||
namespace duckdb { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
#include <cstdint> | ||
|
||
namespace duckdb { | ||
|
||
struct ReqStats { | ||
float elapsed_sec; | ||
uint64_t read_bytes; | ||
uint64_t read_rows; | ||
}; | ||
|
||
} // namespace duckdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#include "duckdb/main/query_result.hpp" | ||
#include "yyjson.hpp" | ||
|
||
namespace duckdb { | ||
using namespace duckdb_yyjson; // NOLINT(*-build-using-namespace) | ||
|
||
class ResultSerializer { | ||
public: | ||
explicit ResultSerializer(const bool _set_invalid_values_to_null = false) | ||
: set_invalid_values_to_null(_set_invalid_values_to_null) { | ||
doc = yyjson_mut_doc_new(nullptr); | ||
} | ||
|
||
virtual ~ResultSerializer() { | ||
yyjson_mut_doc_free(doc); | ||
} | ||
|
||
std::string YY_ToString() { | ||
auto data = yyjson_mut_write(doc, 0, nullptr); | ||
if (!data) { | ||
throw SerializationException("Could not render yyjson document"); | ||
} | ||
std::string json_output(data); | ||
free(data); | ||
return json_output; | ||
} | ||
|
||
protected: | ||
void SerializeInternal(QueryResult &query_result, yyjson_mut_val *append_root, bool values_as_array); | ||
|
||
void SerializeChunk(const DataChunk &chunk, vector<string> &names, vector<LogicalType> &types, | ||
yyjson_mut_val *append_root, bool values_as_array); | ||
|
||
yyjson_mut_val *SerializeRowAsArray(const DataChunk &chunk, idx_t row_idx, vector<LogicalType> &types); | ||
|
||
yyjson_mut_val *SerializeRowAsObject(const DataChunk &chunk, idx_t row_idx, vector<string> &names, | ||
vector<LogicalType> &types); | ||
|
||
void SerializeValue(yyjson_mut_val *parent, const Value &value, optional_ptr<string> name, const LogicalType &type); | ||
|
||
yyjson_mut_doc *doc; | ||
bool set_invalid_values_to_null; | ||
}; | ||
} // namespace duckdb |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we perhaps want to remove
read_bytes
andread_rows
until they are used @lmangani ? Otherwise people will just be confusedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI
read_bytes
andread_rows
are only used by the UI to display the results and emulate Clickhouse query statsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But aren't hey always 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They shouldn't be when using the JSONCompact format but I'll re-check