Skip to content
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

builtin: add {de,}compress builtins #67426

Merged
merged 1 commit into from Jul 14, 2021
Merged

Conversation

pbardea
Copy link
Contributor

@pbardea pbardea commented Jul 9, 2021

demo@127.0.0.1:26257/movr> select compress('hello there', 'gzip');
                                                        compress
------------------------------------------------------------------------------------------------------------------------
  \037\213\010\000\000\000\000\000\000\377\312H\315\311\311W(\311H-J\005\004\000\000\377\377P\351\022m\013\000\000\000
(1 row)

demo@127.0.0.1:26257/movr> select decompress(compress('hello there', 'gzip'), 'gzip');
  decompress
---------------
  hello there
(1 row)

demo@127.0.0.1:26257/movr> select length(repeat('hi there', 100)::bytes);
  length
----------
     800
(1 row)

demo@127.0.0.1:26257/movr> select length(compress(repeat('hi there', 100)::bytes, 'gzip'));
  length
----------
      39
(1 row)

demo@127.0.0.1:26257/movr> select decompress('not compressed', 'gzip');
ERROR: decompress(): failed to decompress: gzip: invalid header
demo@127.0.0.1:26257/movr> select decompress('bad codec', 'zip');
ERROR: decompress(): only 'gzip' codec is supported for decompress()
SQLSTATE: 22023

This commits adds builtins to compress and decompress bytes. The only
codec currently supported is gzip.

Release note (sql change): New builtins, compress(data, codec) and
decompress(data, codec), are added which can compress and decompress
bytes with the specified codec. Gzip is the only currently supported
codec.

@pbardea pbardea requested a review from dt July 9, 2021 15:19
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@pbardea pbardea force-pushed the gzip-builtin branch 2 times, most recently from 3984cd4 to 81453d4 Compare July 9, 2021 15:29
@dt
Copy link
Member

dt commented Jul 9, 2021

naming bikeshed:
should we make it de/compress(bytes, codec) similar to encode(payload, format) in case we add more compression codecs?

This commits adds builtins to compress and decompress bytes. The only
codec currently supported is `gzip`.

Release note (sql change): New builtins, compress(data, codec) and
decompress(data, codec), are added which can compress and decompress
bytes with the specified codec.  Gzip is the only currently supported
codec.
@pbardea pbardea changed the title builtin: add gzip_{de,}compress methods builtin: add {de,}compress builtins Jul 9, 2021
@pbardea
Copy link
Contributor Author

pbardea commented Jul 9, 2021

Good idea! Updated.

@pbardea pbardea requested a review from dt July 13, 2021 14:30
@pbardea
Copy link
Contributor Author

pbardea commented Jul 14, 2021

TFTR
bors r+

@craig
Copy link
Contributor

craig bot commented Jul 14, 2021

Build failed:

@pbardea
Copy link
Contributor Author

pbardea commented Jul 14, 2021

One more time.
bors r+

@craig
Copy link
Contributor

craig bot commented Jul 14, 2021

Build succeeded:

@craig craig bot merged commit 84f7aa0 into cockroachdb:master Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants