Skip to content

Commit 566845b

Browse files
committed
Most of the mappings in
1 parent 47108e3 commit 566845b

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

src/from_substrait.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const std::unordered_map<std::string, std::string> SubstraitToDuckDB::function_n
3030
{"modulus", "mod"}, {"std_dev", "stddev"}, {"starts_with", "prefix"},
3131
{"ends_with", "suffix"}, {"substring", "substr"}, {"char_length", "length"},
3232
{"is_nan", "isnan"}, {"is_finite", "isfinite"}, {"is_infinite", "isinf"},
33-
{"like", "~~"}, {"extract", "date_part"}};
33+
{"like", "~~"}, {"extract", "date_part"}, {"bitwise_and", "&"},
34+
{"bitwise_or", "|"}, {"bitwise_xor", "xor"}};
3435

3536
const case_insensitive_set_t SubstraitToDuckDB::valid_extract_subfields = {
3637
"year", "month", "day", "decade", "century", "millenium",

src/to_substrait.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ const std::unordered_map<std::string, std::string> DuckDBToSubstrait::function_n
3838
{"+", "add"},
3939
{"/", "divide"},
4040
{"first", "any_value"},
41-
{"!~~", "not_equal"}};
41+
{"!~~", "not_equal"},
42+
{"&", "bitwise_and"},
43+
{"|", "bitwise_or"},
44+
{"xor", "bitwise_xor"}};
4245

4346
const case_insensitive_set_t DuckDBToSubstrait::valid_extract_subfields = {
4447
"year", "month", "day", "decade", "century", "millenium",

test/sql/test_functions.test

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# name: test/sql/test_functions.test
2+
# description: Test functions roundtrip
3+
# group: [sql]
4+
5+
require substrait
6+
7+
statement ok
8+
PRAGMA enable_verification
9+
10+
statement ok
11+
create table t as select 1 as a ,2 as b;
12+
13+
# bitwise_and
14+
statement ok
15+
CALL get_substrait('select a & b from t')
16+
17+
# bitwise_or
18+
statement ok
19+
CALL get_substrait('select a | b from t')
20+
21+
# bitwise_xor
22+
statement ok
23+
CALL get_substrait('select xor(a,b) from t')
24+
25+
# octet_length
26+
#statement ok
27+
#CALL get_substrait('select octet_length(''100001'') from t')
28+
29+
# coalesce
30+
statement ok
31+
CALL get_substrait('select coalesce(a) from t')
32+
33+
# acosh
34+
# asinh
35+
# atanh
36+
# cosh
37+
# sinh
38+
# tanh
39+
statement ok
40+
CALL get_substrait('select acosh(a),asinh(a),atanh(a),cosh(a),sinh(a),tanh(a) from t')

0 commit comments

Comments
 (0)