Skip to content

Commit a91b415

Browse files
handling mixed const and column data
1 parent 61fb765 commit a91b415

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/Functions/FunctionsBech32Representation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ class EncodeToBech32Representation : public IFunction
159159
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override
160160
{
161161
bool have_witver = arguments.size() == 3;
162-
const ColumnPtr & col0 = arguments[0].column;
163-
const ColumnPtr & col1 = arguments[1].column;
162+
ColumnPtr col0 = arguments[0].column->convertToFullColumnIfConst();
163+
ColumnPtr col1 = arguments[1].column->convertToFullColumnIfConst();
164164
ColumnPtr col2;
165165
if (have_witver)
166166
col2 = arguments[2].column;

tests/queries/0_stateless/03512_bech32_enc_dec.reference

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ bc1w508d6qejxtdg4y5r3zarvary0c5xw7k8zcwmq
1313
bc1w508d6qejxtdg4y5r3zarvary0c5xw7kj7gz7z
1414
1
1515
bc 751E76E8199196D454941C45D1B3A323F1433BD6
16+
bc1v6r3z2nw4k6d3rffc7j9mftwluxz8v8pfe6h6syw7j5lwr
17+
bc1v6r3z2nw4k6d3rffc7j9mftwluxz8v8pfe6h6syw7j5lwr
18+
bc1v6r3z2nw4k6d3rffc7j9mftwluxz8v8pfe6h6syw7j5lwr
1619
bc1v6r3z2nw4k6d3rffc7j9mftwluxz8v8pfe6h6syw7j5lwr bc1v6r3z2nw4k6d3rffc7j9mftwluxz8v8pfe6h6sywtwyntp 1 1 1
1720
tb137xd6smyhd7u5ywyjapa5tzt2srzlgpc3wleysrcwmcmel tb137xd6smyhd7u5ywyjapa5tzt2srzlgpc3wleysrcwmcmel 1 1 1
1821
bc12zuq63wvya0nd66lktpz4ylk5n5rh2fcpe2uvlm2cdq5mu bc12zuq63wvya0nd66lktpz4ylk5n5rh2fcpe2uvlm2cdq5mu 1 1 1

tests/queries/0_stateless/03512_bech32_enc_dec.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ INSERT INTO hex_data VALUES
5050
('tb', 'b103a1937c6e2fb9de707a4be02d5d39e217b4bca7ce3c9c12', 0),
5151
('bcrt', '95eb334ff82ef8ad76151c29094abdae6c9e8bb8244523e347', 2);
5252

53+
-- test const hrp with column data
54+
SELECT bech32Encode('bc', unhex(data)) FROM hex_data limit 1;
55+
56+
-- test const data with column hrp
57+
SELECT bech32Encode(hrp, unhex('6687112a6eadb4d88d29c7a45da56eff0c23b0e14e757d408e')) FROM hex_data limit 1;
58+
59+
-- test column hrp and data with const witver
60+
SELECT bech32Encode(hrp, unhex(data), 1) FROM hex_data limit 1;
61+
5362
-- for encoding, if using a FixedString column for the data it is crucial that there is no padding
5463
-- since the input is binary, there is no way to check for it
5564
CREATE TABLE bech32_test

0 commit comments

Comments
 (0)