Skip to content

Conversation

@BanBuDu0
Copy link
Contributor

@BanBuDu0 BanBuDu0 commented Apr 21, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

According to #8937.
The encode and decode function are implemented in this pull request.

Checklist For Contributors

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • I have demonstrated that backward compatibility is not broken by breaking changes and created issues to track deprecated features to be removed in the future. (Please refer to the issue)
  • All checks passed in ./risedev check (or alias, ./risedev c)

Checklist For Reviewers

  • I have requested macro/micro-benchmarks as this PR can affect performance substantially, and the results are shown.

Documentation

  • My PR DOES NOT contain user-facing changes.
Click here for Documentation

Types of user-facing changes

Please keep the types that apply to your changes, and remove the others.

  • Installation and deployment
  • Connector (sources & sinks)
  • SQL commands, functions, and operators
  • RisingWave cluster configuration changes
  • Other (please specify in the release note below)

Release note

@lmatz
Copy link
Contributor

lmatz commented Apr 21, 2023

Could you help enable the test cases here:

@BanBuDu0
Copy link
Contributor Author

BanBuDu0 commented Apr 21, 2023

SELECT encode(('\x' || repeat('1234567890abcdef0001', 7))::bytea, 'base64');
SELECT decode(encode(('\x' || repeat('1234567890abcdef0001', 7))::bytea, 'base64'), 'base64');
These two sqls will produce an error:
ERROR: QueryError: Bind error: cannot cast type "varchar" to "bytea" in Explicit context

Seems like an error happend in compile-time which cast expr bind error.
I see that no Bytea type mentioned in CAST_MAP https://github.com/risingwavelabs/risingwave/blob/main/src/expr/src/sig/cast.rs#L51

@BanBuDu0
Copy link
Contributor Author

SELECT encode(('\x' || repeat('1234567890abcdef0001', 7))::bytea, 'base64'); SELECT decode(encode(('\x' || repeat('1234567890abcdef0001', 7))::bytea, 'base64'), 'base64'); These two sqls will produce an error: ERROR: QueryError: Bind error: cannot cast type "varchar" to "bytea" in Explicit context

Seems like an error happend in compile-time which cast expr bind error. I see that no Bytea type mentioned in CAST_MAP https://github.com/risingwavelabs/risingwave/blob/main/src/expr/src/sig/cast.rs#L51

I see that the cast function [varchar->bytea] was already implemented here https://github.com/risingwavelabs/risingwave/blob/main/src/expr/src/vector_op/cast.rs#L196

So I fix it by simple add Bytea type to CAST_MAP, see commit:432b705
Is there something wrong with this fix?

@lmatz lmatz requested a review from xiangjinwu April 22, 2023 05:03
Copy link
Contributor

@xiangjinwu xiangjinwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. And your fix to the CAST_MAP is correct.

sunyuejun.re added 2 commits April 23, 2023 19:19
src/tests/regress/data/sql/strings.sql
@BanBuDu0
Copy link
Contributor Author

BanBuDu0 commented Apr 23, 2023

After I changed the CAST_MAP, I should also modify the e2e_test/batch/catalog/pg_cast.slt.part, which the catalog was
following the changes of CAST_MAP.
By the way, I also fixed the from_oid function here https://github.com/risingwavelabs/risingwave/blob/main/src/common/src/types/postgres_type.rs#L48, there was no Bytea before.
See 186bc93

Finally, all the test was passsed now🥳.

Copy link
Contributor

@lmatz lmatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for your contribution!

@lmatz lmatz added this pull request to the merge queue Apr 24, 2023
Merged via the queue into risingwavelabs:main with commit 0fe6f59 Apr 24, 2023
@BanBuDu0 BanBuDu0 deleted the feat-encdec branch April 24, 2023 13:28
@neverchanje neverchanje added the user-facing-changes Contains changes that are visible to users label May 16, 2023
@CharlieSYH CharlieSYH added the 📖✓ Covered or will be covered in the user docs. label May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

user-facing-changes Contains changes that are visible to users 📖✓ Covered or will be covered in the user docs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants