Fix for casting tdigest to text and vice versa #1
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.
As discussed; we ran into an issue when you cast a
tdigest
totext
and later back totdigest
.The
char *centroids
would only contain the data till the first word break. Instead we introduce the use of%n
to count the length of the data captured by the header. This gets added to thechar *str
and captured inptr
before parsing the centroids on their own.While working on this patch I also ran into
pq_getmsgint(buf, sizeof(int64));
being called. According to the documentation in pqformat.c Postgres decided to not implement the 64 bit variant:I think this gets used when you store a
tdigest
in a relation, so I also added a test at the end that will store sometdigest
data in a table that gets combined into the finaltdigest
before verifying the correctness of the results.